Skip to content

Commit

Permalink
Added test for Issue #37
Browse files Browse the repository at this point in the history
  • Loading branch information
hgrecco committed Jul 26, 2013
1 parent 4efacdc commit ab0d05b
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion pint/testsuite/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
from pint.unit import UnitsContainer
from pint.util import ParserHelper

from pint.testsuite import HAS_NUMPY, np, TestCase

class TestIssues(unittest.TestCase):

def _test_issue25(self):
@unittest.expectedFailure
def test_issue25(self):
x = ParserHelper.from_string('10 %')
self.assertEqual(x, ParserHelper(10, {'%': 1}))
x = ParserHelper.from_string('10 ‰')
Expand All @@ -31,3 +34,22 @@ def test_issue29(self):
self.assertEqual(t.magnitude, 4)
self.assertEqual(t.units, UnitsContainer(millimolar=1))
self.assertEqual(t.to('mole / liter'), 4e-3 * ureg['M'])


@unittest.skipUnless(HAS_NUMPY, 'Numpy not present')
class TestIssuesNP(TestCase):

FORCE_NDARRAY = False

@unittest.expectedFailure
def test_issue37(self):
x = np.ma.masked_array([1, 2, 3], mask=[True, True, False])
ureg = UnitRegistry()
q = ureg.meter * x
self.assertIsInstance(q, ureg.Quantity)
self.assertSequenceEqual(q.magnitude, x)
self.assertEquals(q.units, ureg.meter.units)
q = x * ureg.meter
self.assertIsInstance(q, ureg.Quantity)
self.assertSequenceEqual(q.magnitude, x)
self.assertEquals(q.units, ureg.meter.units)

0 comments on commit ab0d05b

Please sign in to comment.