Commit 83255aa8 authored by Jason Swails's avatar Jason Swails
Browse files

Add test for numpy units and update user's guide docs.

parent 4ae68749
...@@ -2865,7 +2865,7 @@ in and out. ...@@ -2865,7 +2865,7 @@ in and out.
[[10.0, 20.0, 30.0], [40.0, 50.0, 60.0]] [[10.0, 20.0, 30.0], [40.0, 50.0, 60.0]]
>>> import numpy >>> import numpy
>>> a = Quantity(numpy.array([1,2,3]), centimeter) >>> a = numpy.array([1,2,3]) * centimeter
>>> print(a) >>> print(a)
[1 2 3] cm [1 2 3] cm
>>> print(a/millimeter) >>> print(a/millimeter)
......
...@@ -638,6 +638,7 @@ class TestUnits(QuantityTestCase): ...@@ -638,6 +638,7 @@ class TestUnits(QuantityTestCase):
self.assertEqual(str(u.meters*u.meters), 'meter**2') self.assertEqual(str(u.meters*u.meters), 'meter**2')
self.assertEqual(str(u.meter*u.meter), 'meter**2') self.assertEqual(str(u.meter*u.meter), 'meter**2')
@unittest.skipIf(np is None, 'Skipping numpy units tests')
class TestNumpyUnits(QuantityTestCase): class TestNumpyUnits(QuantityTestCase):
def testNumpyQuantity(self): def testNumpyQuantity(self):
...@@ -686,6 +687,6 @@ class TestNumpyUnits(QuantityTestCase): ...@@ -686,6 +687,6 @@ class TestNumpyUnits(QuantityTestCase):
b = a.reshape((5, 2)) b = a.reshape((5, 2))
self.assertTrue(u.is_quantity(b)) self.assertTrue(u.is_quantity(b))
if np is None: def testMultiplication(self):
# Support lack of numpy """ Tests that units override numpy.ndarray multiplication """
del TestNumpyUnits self.assertIsInstance(np.arange(10)*u.angstroms, u.Quantity)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment