Commit 1f0e141b authored by peastman's avatar peastman
Browse files

Merge pull request #985 from swails/bool_unit

Fix Python 3 support in unit package.
parents 96f0c0f2 24f6585e
......@@ -603,7 +603,7 @@ class Quantity(object):
return bool(self._value)
def __bool__(self):
return self.__nonzero__()
return bool(self._value)
def __complex__(self):
return Quantity(complex(self._value), self.unit)
......@@ -818,7 +818,6 @@ def _is_string(x):
except StopIteration:
return False
# run module directly for testing
if __name__=='__main__':
# Test the examples in the docstrings
......
......@@ -448,7 +448,7 @@ class TestUnits(QuantityTestCase):
self.assertAlmostEqualQuantities(n, 2.05834818672e-17 * u.mole)
self.assertAlmostEqualQuantities(V, 5.2359833333333e-19 * u.meters**3)
self.assertEqual(str(T), '310.0 K')
self.assertEqual(str(u.MOLAR_GAS_CONSTANT_R), '8.31447247122 J/(K mol)')
self.assertEqual(str(1*u.joules/u.kelvin/u.mole), '1 J/(K mol)')
self.assertTrue(u.is_quantity(V))
# Checks trouble with complicated unit conversion factors
p1 = 1.0 * u.atmospheres
......
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