NumPy exp and log keeps the type
Previous behaviour: when it`s passed a dimensionless quantity, it does not return a dimensionless quantity; it returns a standard numpy array (or scalar) New behaviour: returns a dimensionless quantity. Breaking Change: to regain the old behaviour, get the magnitude of the resulting value. e.g. >>> np.log(5 * ureg.dimensionless).magnitude Close #95
This commit is contained in:
parent
a82460f659
commit
c4b9d10a3b
|
@ -1052,6 +1052,7 @@ class _Quantity(SharedRegistryObject):
|
|||
#: will set on output.
|
||||
__set_units = {'cos': '', 'sin': '', 'tan': '',
|
||||
'cosh': '', 'sinh': '', 'tanh': '',
|
||||
'log': '', 'exp': '',
|
||||
'arccos': __radian, 'arcsin': __radian,
|
||||
'arctan': __radian, 'arctan2': __radian,
|
||||
'arccosh': __radian, 'arcsinh': __radian,
|
||||
|
|
|
@ -530,3 +530,8 @@ class TestIssuesNP(QuantityTestCase):
|
|||
'1 count')
|
||||
self.assertEqual('{0:~}'.format(1 * self.ureg('MiB')),
|
||||
'1 MiB')
|
||||
|
||||
def test_issue482(self):
|
||||
q = self.ureg.Quantity(1, self.ureg.dimensionless)
|
||||
qe = np.exp(q)
|
||||
self.assertIsInstance(qe, self.ureg.Quantity)
|
||||
|
|
Loading…
Reference in New Issue