You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Should numpy function automatically use .simplified? #152
>>> import numpy as np
>>> import quantities as pq
>>> np.exp(3*pq.joule/(2*pq.cal))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/py36/lib/python3.6/site-packages/quantities/quantity.py", line 247, in __array_prepare__
res._dimensionality = p_dict[uf](*objs)
File "/opt/py36/lib/python3.6/site-packages/quantities/dimensionality.py", line 358, in _d_dimensionless
raise ValueError("quantity must be dimensionless")
ValueError: quantity must be dimensionless
>>> patched_exp = lambda x: np.exp(x.simplified if hasattr(x, 'simplified') else x)
>>> patched_exp(3*pq.joule/(2*pq.cal))
array(1.43119335) * dimensionless
I would like to see this working automatically (I haven't looked into whether this can be fixed easily or if we need to wait for __array_function__ in NumPy)
changed the title [-]Should numpy function automatically use `.simplified`?[/-][+]Should numpy function automatically use .simplified?[/+]on Feb 1, 2019
Activity
[-]Should numpy function automatically use `.simplified`?[/-][+]Should numpy function automatically use .simplified?[/+]