Skip to content

Commit

Permalink
pybamm-team#1230 coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsulzer committed Nov 24, 2020
1 parent 27641d3 commit f1134a9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions pybamm/expression_tree/input_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def set_expected_size(self, size):
# We also need to update the saved size and shape
self._saved_size = size
self._saved_shape = (size, 1)
self._saved_evaluate_for_shape = self._evaluate_for_shape()

def _evaluate_for_shape(self):
"""
Expand Down
23 changes: 10 additions & 13 deletions pybamm/solvers/base_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,20 +841,17 @@ def step(
termination = self.get_termination_reason(solution, model.events)

pybamm.logger.debug("Finish stepping {} ({})".format(model.name, termination))
if set_up_time:
pybamm.logger.debug(
(
"Set-up time: {}, Step time: {} (of which integration time: {}), "
"Total time: {}"
).format(
solution.set_up_time,
solution.solve_time,
solution.integration_time,
solution.total_time,
)
pybamm.logger.debug(
(
"Set-up time: {}, Step time: {} (of which integration time: {}), "
"Total time: {}"
).format(
solution.set_up_time,
solution.solve_time,
solution.integration_time,
solution.total_time,
)
else:
pybamm.logger.debug("Step time: {}".format(solution.solve_time))
)
if save is False or old_solution is None:
return solution
else:
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_expression_tree/test_input_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def test_evaluate_for_shape(self):

a.set_expected_size(10)
self.assertEqual(a.shape, (10, 1))
np.testing.assert_equal(a.evaluate_for_shape(), np.nan * np.ones((10, 1)))
self.assertEqual(a.evaluate_for_shape().shape, (10, 1))

def test_errors(self):
a = pybamm.InputParameter("a")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def test_functions(self):
np.testing.assert_array_equal(jacobian, dfunc_dy.toarray())

# when child evaluates to number
func = pybamm.sin(const)
func = pybamm.Sin(const)
dfunc_dy = func.jac(y).evaluate(y=y0)
np.testing.assert_array_equal(0, dfunc_dy)

Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def test_timer_operations(self):
self.assertEqual((pybamm.TimerTime(1) - pybamm.TimerTime(2)).value, -1)
self.assertEqual((1 - pybamm.TimerTime(1)).value, 0)
self.assertEqual((pybamm.TimerTime(4) * 2).value, 8)
self.assertEqual((pybamm.TimerTime(4) * pybamm.TimerTime(2)).value, 8)
self.assertEqual((2 * pybamm.TimerTime(5)).value, 10)
self.assertEqual((pybamm.TimerTime(4) / 2).value, 2)
self.assertEqual((pybamm.TimerTime(4) / pybamm.TimerTime(2)).value, 2)
Expand Down

0 comments on commit f1134a9

Please sign in to comment.