Skip to content

Commit

Permalink
#871 fix coverage and remove redundant test
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsulzer committed Mar 13, 2020
1 parent bcfba9f commit 6bac2d7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 131 deletions.
130 changes: 0 additions & 130 deletions tests/integration/test_quick_plot.py

This file was deleted.

37 changes: 36 additions & 1 deletion tests/unit/test_quick_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ def test_simple_ode_model(self):
model.variables["Negative 2D variable"] = model.variables["2D variable"]
quick_plot = pybamm.QuickPlot(solution, ["Negative 2D variable"])
quick_plot.plot(0)
quick_plot.dynamic_plot(testing=True)
quick_plot.slider_update(0.01)

with self.assertRaisesRegex(NotImplementedError, "Cannot plot 2D variables"):
pybamm.QuickPlot([solution, solution], ["2D variable"])
Expand All @@ -182,7 +184,7 @@ def test_simple_ode_model(self):
with self.assertRaisesRegex(ValueError, "Mismatching variable domains"):
pybamm.QuickPlot(solution, [["a", "b broadcasted"]])
with self.assertRaisesRegex(ValueError, "labels"):
quick_plot = pybamm.QuickPlot(
pybamm.QuickPlot(
[solution, solution], ["a"], labels=["sol 1", "sol 2", "sol 3"]
)

Expand Down Expand Up @@ -234,6 +236,39 @@ def test_loqs_spm_base(self):
]
pybamm.QuickPlot(solution, output_variables)

def test_plot_2plus1D_spm(self):
spm = pybamm.lithium_ion.SPM(
{"current collector": "potential pair", "dimensionality": 2}
)
geometry = spm.default_geometry
param = spm.default_parameter_values
param.process_model(spm)
param.process_geometry(geometry)
var = pybamm.standard_spatial_vars
var_pts = {
var.x_n: 5,
var.x_s: 5,
var.x_p: 5,
var.r_n: 5,
var.r_p: 5,
var.y: 5,
var.z: 5,
}
mesh = pybamm.Mesh(geometry, spm.default_submesh_types, var_pts)
disc_spm = pybamm.Discretisation(mesh, spm.default_spatial_methods)
disc_spm.process_model(spm)
t_eval = np.linspace(0, 3600, 100)
solution_spm = spm.default_solver.solve(spm, t_eval)

pybamm.QuickPlot(
solution_spm,
[
"Negative current collector potential [V]",
"Positive current collector potential [V]",
"Terminal voltage [V]",
],
)

def test_failure(self):
with self.assertRaisesRegex(TypeError, "solutions must be"):
pybamm.QuickPlot(1)
Expand Down

0 comments on commit 6bac2d7

Please sign in to comment.