-
Notifications
You must be signed in to change notification settings - Fork 405
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
Unit message helper #377
Unit message helper #377
Conversation
Some units (like inHg) have a problem with the fractional exponent and then being converted to dimensionless. Instead, manually ensure this before taking the power.
This can be used to decorate calculation functions, providing checking of the dimensionality of paramters and raising helpful messages when improper arguments are provided. This requires function signature support from Python >= 3.3. On Python 2.7, this decorator is a no-op at runtime, but provides no checking. Pint has its own `check` decorator, but unfortunately this doesn't provide very helpful error messages.
This should only be applying where it's not going to break API.
Well, the "quality" checkers all hate this for stupid reasons. Ignore those. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming all the tests pass, I'll merge if you're ready. It looks good and I think you hit all of the relevant calculations.
It's ready, but travis seems to be having issues 😭 |
Looks like we're good to go here. |
This adds a decorator that allows us to decorate functions with the dimensionality of arguments (as positional or keyword arguments):
Sane handling of positional and keyword arguments relies on function signature arguments added to the
inspect
module in Python >= 3.3. Thus this isn't available on Python 2.7, and at run time this is a no-op there.Closes #175.