Skip to content

Commit

Permalink
#858 improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
martinjrobins committed Mar 16, 2020
1 parent 345be6a commit 0c5270e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/unit/test_expression_tree/test_operations/test_jac.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ def test_nonlinear(self):
dfunc_dy = func.jac(y).evaluate(y=y0)
np.testing.assert_array_equal(jacobian, dfunc_dy.toarray())

def test_multislice_raises(self):
y1 = pybamm.StateVector(slice(0, 4), slice(7, 8))
y2 = pybamm.StateVector(slice(4, 7))
with self.assertRaises(NotImplementedError):
y1.jac(y1)
with self.assertRaises(NotImplementedError):
y2.jac(y1)

def test_linear_ydot(self):
y = pybamm.StateVector(slice(0, 4))
y_dot = pybamm.StateVectorDot(slice(0, 4))
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/test_expression_tree/test_symbolic_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ def test_diff_zero(self):
self.assertEqual(func.diff(b).id, pybamm.Scalar(0).id)
self.assertNotEqual(func.diff(a).id, pybamm.Scalar(0).id)

def test_diff_state_vector_dot(self):
a = pybamm.StateVectorDot(slice(0, 1))
b = pybamm.StateVector(slice(1, 2))
self.assertEqual(a.diff(a).id, pybamm.Scalar(1).id)
self.assertEqual(a.diff(b).id, pybamm.Scalar(0).id)

def test_diff_heaviside(self):
a = pybamm.Scalar(1)
b = pybamm.StateVector(slice(0, 1))
Expand Down

0 comments on commit 0c5270e

Please sign in to comment.