kdavies4 / natu

Natural units in Python
http://kdavies4.github.io/natu/
Other
33 stars 5 forks source link

sqrt doesn't work on arrays? #27

Open endolith opened 8 years ago

endolith commented 8 years ago
from natu.units import V
from natu.math import sqrt

sqrt(V**2)
Out[2]: ScalarUnit V with dimension L(2)*M/(I*T(3)) (not prefixable)

V**2
Out[3]: ScalarUnit V2 with dimension L4*M2/(I2*T6) (not prefixable)

(array([3,4,5])*V)**2
Out[4]: array([9 V2, 16 V2, 25 V2], dtype=object)

(V*array([3,4,5]))**2
Out[5]: [  9.  16.  25.] V2

sqrt((V*array([3,4,5]))**2)
Traceback (most recent call last):
...
TypeError: only length-1 arrays can be converted to Python scalars

sqrt((array([3,4,5])*V)**2)
Traceback (most recent call last):
...
TypeError: only length-1 arrays can be converted to Python scalars