Skip to content
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

Quantity changes behavior depending on presence of abbrev parameter #20095

Open
TvanVuure opened this issue Sep 16, 2020 · 5 comments
Open

Quantity changes behavior depending on presence of abbrev parameter #20095

TvanVuure opened this issue Sep 16, 2020 · 5 comments
Labels
physics.units Units and dimensions

Comments

@TvanVuure
Copy link

afbeelding

@TvanVuure TvanVuure changed the title Qua Quantity changes behavior depending on presence of abbrev parameter Sep 16, 2020
@TvanVuure
Copy link
Author

I came across the above peculiar behavior, and I find it very confusing.
The "abbrev" parameter is not very clear to me, but it seems that the purpose is to override the printing of the scale_factor with an abbreviation. I don't know what good that does anyone.
But even if that is the purpose, it cannot be right that the scale_factor is of type Dimension.
Also, it seems that the n() method does not know how to handle the output of parentheses, or maybe the multiplier object.

@TvanVuure
Copy link
Author

afbeelding

@TvanVuure
Copy link
Author

More peculiar behavior: in the absence of an "abbrev" parameter the method .convert_to does not seem to work properly.

@TvanVuure
Copy link
Author

afbeelding

@TvanVuure
Copy link
Author

More weirdness, see above.
If I define a quantity, and then substitute an expression for that quantity that is really a "mul" of a number and a unit, then Sympy incorrectly copies the number, as if the units had some kind of multiplier like "milli" or "kilo". But they don't. This does not happen to other units, like meter and millimeter.
I would rather not use "mul"s of a number and a unit, but Sympy makes it very hard to directly get the right number into the Quantity.
In case anyone is wondering what I am up to, I am trying to mimic Mathcad's behavior, so I can see my equations in PrettyPrint in Jupyter, and at the same time use the output in a further calculation. I am trying to avoid having two different lines, one PrettyPrinting the formula and one giving the result, in order to maximize traceability of the code.
I assumed this would be the main application of Sympy. After all, most people are not mathematicians. All "example code" in Sympy seems to be from people showing off how cool it is, but not actually using it for something. I am starting to understand why.

@oscarbenjamin oscarbenjamin added the physics.units Units and dimensions label Sep 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
physics.units Units and dimensions
Projects
None yet
Development

No branches or pull requests

2 participants