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
In the PlainQuantity class the method dimensionality() only updates the dimensionality of the object when it is previously None. This is causing issues when working with numpy ndarray quantitites and in-place operations.
For example:
import numpy as np
from pint import UnitRegistry
ureg = UnitRegistry()
quantity = ureg.Quantity
# create a numpy array based quantity
x = quantity(np.array([[20.0]],"m")
print(x.dimensionality) # returns {'[length]':1.0}
# divide by 1m to get a dimenstionless quantity using in-place operation
x /= quantity(1,"m")
print(x.dimensionality) # still returns {'[length]':1.0}
Becuase the array was modified in place, a new object was not created and therefore the dimensionality was not reset to None. Subsequent calls to dimensionality do not reflect the changes caused by the division.
The text was updated successfully, but these errors were encountered:
In the PlainQuantity class the method
dimensionality()
only updates the dimensionality of the object when it is previouslyNone
. This is causing issues when working with numpyndarray
quantitites and in-place operations.For example:
Becuase the array was modified in place, a new object was not created and therefore the
dimensionality
was not reset toNone
. Subsequent calls todimensionality
do not reflect the changes caused by the division.The text was updated successfully, but these errors were encountered: