-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mixed-unit vectors and matrices #1385
Comments
No I don't think you can work with mixed units with quantities & keep numpy operations, just like you cannot work with mixed dtypes with numpy. Numpy have made some steps towards metadata inside DTypes (https://numpy.org/neps/nep-0041-improved-dtype-support.html) but even there you need to have one unit per arrays or matrix. A custom function with |
Ok thank you very much for the answer, I appreciate it! I will just keep Pint "at the edges" like you suggest. Since it feels like from your response that this is solidly out-of-scope, I'm happy for this to be closed. |
Closing this |
Related: I came across this trying to invert a matrix with mixed units. This appears e.g. with stiffness matrices for rigid bodies, which have a 3x3 submatrix with a unit pattern (using SI units). The force equations read
where f, q are six-vectors of mixed dimensions (force and torque, distance and angle), resulting in an overall pattern (using SI units Newton, meters, seconds)
For inverting, being unable to store units this way and perform operations on them, leads to significant added complexity or loss of the tracking of units of the properties. Mostly it means having to do the “units math” by hand. (Side remark: Also ties in a bit to #1288, due to the question of what of these terms should have “rad” added, when being explicit about it, which when done badly could even make the matrix uninvertible due to the units, I think.) |
I'm working with some code that defines vectors and transformation matrices that operate on those vectors.
A simplified (2D) example is something like this:
The result is
array([5, 2])
, meaning the particle now has position "5 mm" and the same angle "2 mrad". But clearly if I got the units of the "particle" wrong and used units['m', 'deg']
then my answer would be wrong.In the 2D case, I might just explicitly write out the matrix math, and not use vectors/arrays. However in reality I'm interested in doing this for matrices that are up to 24x24.
Is there is any way to express this with Pint?
The text was updated successfully, but these errors were encountered: