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 came from he pint package, disappointed with its numpy support to scimath in hopes that the UnitArray could present some interesting possibilities. Unfortunately this is not the case. I would like to run a unit-aware dot product using 2 unit arrays, but this won't work:
a = UnitArray(np.linspace(0, 5, 6), units="cm")
b = UnitArray(np.linspace(0, 9, 6), units="sec")
c = np.dot(a,b)
type(c) shows that this is a numpy.float64 object and not a UnitArray of length 0 or a UnitScalar as I would expect. This makes it difficult for me to see the use of UnitArrays since they currently only appear to support element wise multiplication in numpy...
Is there a concise way of doing a unit-aware dot product with scimath? If so how? If not how to implement it?
The text was updated successfully, but these errors were encountered:
We didn't have the use-case for dot with UnitArrays when we wrote the code, but you are right that it makes sense. Fixing would be just a matter of adding a dot method to the UnitArray class that did the right thing with the units. Unfortunately at Enthought we don't have bandwidth for working on SciMath in the near-term, but we would happily accept a pull request implementing this feature.
In the interim, the best work-around for you in your own code is possibly to monkeypatch UnitArray with a dot product method:
I came from he
pint
package, disappointed with itsnumpy
support toscimath
in hopes that theUnitArray
could present some interesting possibilities. Unfortunately this is not the case. I would like to run a unit-aware dot product using 2 unit arrays, but this won't work:type(c)
shows that this is anumpy.float64
object and not aUnitArray
of length 0 or aUnitScalar
as I would expect. This makes it difficult for me to see the use ofUnitArrays
since they currently only appear to support element wise multiplication in numpy...Is there a concise way of doing a unit-aware dot product with
scimath
? If so how? If not how to implement it?The text was updated successfully, but these errors were encountered: