Possibility to disable automatic conversion of units ? #1943
Replies: 2 comments
-
There is no way to do that now, but it is an interesting idea and I do see the potential. You want to force the user to choose the units. Not sure if this can be done without a performance hit. |
Beta Was this translation helpful? Give feedback.
-
Hi, I've just implemented it there : master...raphaeljolivet:pint:feature/strict_mode I added an auto_scale argument to the UnitRegistry (True by default) In the _add_sub method, I check it and raise an exception in case auto_scale is False and the scaling of the other argument is required. It is quite simple and suits my needs. I have not made a proper PR yet. And thanks for this really great library ! Regards, |
Beta Was this translation helpful? Give feedback.
-
Is it possible to disable automatic conversion of units and fail when operation require changing the scale of the quantity ?
I am currently integrating this awesome library into lca_algebraic and would like the option to provide a "strict" mode, forcing users to convert quantities explicitely.
In practice, when this option is set, the following code should fail :
The user should do :
Thanks in advance for your help.
Beta Was this translation helpful? Give feedback.
All reactions