Skip to content

Commit

Permalink
#1429 fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsulzer committed Mar 17, 2021
1 parent cd2ffcd commit e4e9d40
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pybamm/spatial_methods/finite_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ def harmonic_mean(array):
raise ValueError("shift key '{}' not recognised".format(shift_key))

# If discretised_symbol evaluates to number there is no need to average
if discretised_symbol.evaluates_to_number():
if discretised_symbol.size == 1:
out = discretised_symbol
elif method == "arithmetic":
out = arithmetic_mean(discretised_symbol)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_discretisations/test_discretisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def test_process_complex_expression(self):
scal2 = pybamm.Scalar(2)
scal3 = pybamm.Scalar(3)
scal4 = pybamm.Scalar(4)
expression = (scal1 * (scal3 + var2)) / ((var1 - scal4) + scal2)
expression = (scal1 * (scal3 ** var2)) / ((var1 - scal4) + scal2)

# create discretisation
disc = get_discretisation_for_testing()
Expand All @@ -443,7 +443,7 @@ def test_process_complex_expression(self):
# left side
self.assertIsInstance(exp_disc.children[0], pybamm.Multiplication)
self.assertIsInstance(exp_disc.children[0].children[0], pybamm.Scalar)
self.assertIsInstance(exp_disc.children[0].children[1], pybamm.Addition)
self.assertIsInstance(exp_disc.children[0].children[1], pybamm.Power)
self.assertTrue(
isinstance(exp_disc.children[0].children[1].children[0], pybamm.Scalar)
)
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_parameters/test_parameter_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,15 +627,15 @@ def test_process_complex_expression(self):
par2 = pybamm.Parameter("par2")
scal1 = pybamm.Scalar(3)
scal2 = pybamm.Scalar(4)
expression = (scal1 * (par1 + var2)) / ((var1 - par2) + scal2)
expression = (scal1 * (par1 ** var2)) / ((var1 - par2) + scal2)

param = pybamm.ParameterValues(values={"par1": 1, "par2": 2})
exp_param = param.process_symbol(expression)
self.assertIsInstance(exp_param, pybamm.Division)
# left side
self.assertIsInstance(exp_param.children[0], pybamm.Multiplication)
self.assertIsInstance(exp_param.children[0].children[0], pybamm.Scalar)
self.assertIsInstance(exp_param.children[0].children[1], pybamm.Addition)
self.assertIsInstance(exp_param.children[0].children[1], pybamm.Power)
self.assertTrue(
isinstance(exp_param.children[0].children[1].children[0], pybamm.Scalar)
)
Expand Down

0 comments on commit e4e9d40

Please sign in to comment.