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
[I feel like I have had this conversation before, but can't find trace of it anymore. Hope it is not a duplicate]
I keep forgetting that the convert function only works for float, not UnitScalars. As a result, and because UnitScalar is a subclass of np.ndarray, the following happens:
In [3]: from scimath.units.api import convert, UnitScalar
In [4]: x = UnitScalar(1., units="cm")
In [5]: from scimath.units.length import meter
In [6]: convert(x, from_unit=x.units, to_unit=meter)
Out[6]: UnitScalar(0.01, units='0.01*m')
which feels very buggy. I believe that we should:
either raise an exception when a UnitScalar is passed, and create a new convert_unitted function that accepts UnitScalars/UnitArrays
or support the UnitScalars correctly.
I think I like option 2 better, but it makes things not backward compatible, so is probably a no go.
The @has_units decorated function is converting inputs to the units stated but not the outputs. I'm wondering why. If it were it would be trivial to write a convert function for any UnitScalar.
[I feel like I have had this conversation before, but can't find trace of it anymore. Hope it is not a duplicate]
I keep forgetting that the
convert
function only works for float, notUnitScalar
s. As a result, and becauseUnitScalar
is a subclass ofnp.ndarray
, the following happens:which feels very buggy. I believe that we should:
UnitScalar
is passed, and create a newconvert_unitted
function that acceptsUnitScalar
s/UnitArray
sUnitScalar
s correctly.I think I like option 2 better, but it makes things not backward compatible, so is probably a no go.
Opinions? @timdiller @rkern ?
The text was updated successfully, but these errors were encountered: