Skip to content

Commit

Permalink
#1219 fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsulzer committed Nov 3, 2020
1 parent f74142d commit 7c76121
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions pybamm/solvers/casadi_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def _integrate(self, model, t_eval, inputs=None):
# Initialize solution
solution = pybamm.Solution(np.array([t]), y0[:, np.newaxis])
solution.solve_time = 0
solution.integration_time = 0
else:
solution = None

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_expression_tree/test_unary_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def test_smooth_absolute_value(self):
self.assertAlmostEqual(expr.evaluate(y=np.array([-1]))[0, 0], 1)
self.assertEqual(
str(expr),
"y[0:1] * exp(10.0 * y[0:1]) - exp(-10.0 * y[0:1]) "
"/ exp(10.0 * y[0:1]) + exp(-10.0 * y[0:1])",
"y[0:1] * (exp(10.0 * y[0:1]) - exp(-10.0 * y[0:1])) "
"/ (exp(10.0 * y[0:1]) + exp(-10.0 * y[0:1]))",
)

def test_sign(self):
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_solvers/test_solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_append(self):
y1 = np.tile(t1, (20, 1))
sol1 = pybamm.Solution(t1, y1)
sol1.solve_time = 1.5
sol1.integration_time = 0.3
sol1.model = pybamm.BaseModel()
sol1.inputs = {"a": 1}

Expand All @@ -39,11 +40,13 @@ def test_append(self):
y2 = np.tile(t2, (20, 1))
sol2 = pybamm.Solution(t2, y2)
sol2.solve_time = 1
sol2.integration_time = 0.5
sol2.inputs = {"a": 2}
sol1.append(sol2, create_sub_solutions=True)

# Test
self.assertEqual(sol1.solve_time, 2.5)
self.assertEqual(sol1.integration_time, 0.8)
np.testing.assert_array_equal(sol1.t, np.concatenate([t1, t2[1:]]))
np.testing.assert_array_equal(sol1.y, np.concatenate([y1, y2[:, 1:]], axis=1))
np.testing.assert_array_equal(
Expand Down

0 comments on commit 7c76121

Please sign in to comment.