Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoming0625 committed Aug 23, 2024
1 parent 8fa0128 commit e64a90c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions brainunit/_base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def test_inplace_operations(self):
with pytest.raises(NotImplementedError):
inplace_op(volt)

def test_display(self):
assert_equal(str(bu.kmeter / bu.meter), 'Unit(1000.0)')


class TestQuantity(unittest.TestCase):
def test_dim(self):
Expand Down Expand Up @@ -242,6 +245,7 @@ def test_display(self):
display_in_unit(10 * nS, ohm)
assert_equal(display_in_unit(10.0, Unit(scale=1)), "1. * Unit(10.0)")

assert_equal(display_in_unit(3 * bu.kmeter / bu.meter), '3. * Unit(1000.0)')

def test_display2(self):

Expand All @@ -254,7 +258,6 @@ def f(s):
with self.assertRaises(jax.errors.TracerBoolConversionError):
f(2)


def test_unary_operations(self):
q = Quantity(5, unit=mV)
assert_quantity(-q, -5, mV)
Expand Down Expand Up @@ -868,7 +871,7 @@ def test_setiterm(self):
nu = np.asarray([0, 0, 0.])
nu[np.asarray([0, 1, 1])] += np.asarray([1., 1., 1.])
self.assertTrue(np.allclose(nu, np.asarray([1., 1., 0.])))

def test_at(self):
x = jnp.arange(5.0) * bu.mV
with self.assertRaises(bu.UnitMismatchError):
Expand Down

0 comments on commit e64a90c

Please sign in to comment.