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
Handle changed functions in check_units decorator #1612
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dopplershift
added
Area: Units
Pertains to unit information
Type: Enhancement
Enhancement to existing functionality
labels
Dec 17, 2020
So for this code: import metpy.calc as mpcalc
from metpy.units import units
p = 1000 * units.hPa
q = 0.8
t = 27 * units.degC
mpcalc.dewpoint_from_specific_humidity(q, t, p) gives (in Jupyter): ---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-6-eb9bf1fd3039> in <module>
6 t = 27 * units.degC
7
----> 8 mpcalc.dewpoint_from_specific_humidity(q, t, p)
~/repos/metpy/src/metpy/xarray.py in wrapper(*args, **kwargs)
1218
1219 # Evaluate inner calculation
-> 1220 result = func(*bound_args.args, **bound_args.kwargs)
1221
1222 # Wrap output based on match and match_unit
~/repos/metpy/src/metpy/units.py in wrapper(*args, **kwargs)
243 msg = (f'This function changed in {changed_version}--double check '
244 'that the function is being called properly.') + msg
--> 245 raise ValueError(msg)
246 return func(*args, **kwargs)
247
ValueError: This function changed in 1.0--double check that the function is being called properly.`dewpoint_from_specific_humidity` given arguments with incorrect units: `pressure` requires "[pressure]" but given "none", `specific_humidity` requires "[dimensionless]" but given "hectopascal"
Any variable `x` can be assigned a unit as follows:
from metpy.units import units
x = x * units.meter / units.second What do we think? |
dopplershift
force-pushed
the
decorator
branch
2 times, most recently
from
December 19, 2020 04:49
060cbc6
to
85a898b
Compare
Congratulations 🎉. DeepCode analyzed your code in 3.83 seconds and we found no issues. Enjoy a moment of no bugs ☀️. 👉 View analysis in DeepCode’s Dashboard | Configure the bot |
dopplershift
force-pushed
the
decorator
branch
from
December 19, 2020 04:51
85a898b
to
00bc602
Compare
This should be ready for a review. |
This augments the message that comes out from `check_units` based on whether the `versionchanged` sphinx directive is found in the docstring.
Also add a test to make sure the message is working
dopplershift
force-pushed
the
decorator
branch
from
December 21, 2020 07:59
00bc602
to
e2316ea
Compare
dcamron
approved these changes
Dec 21, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description Of Changes
Augment the
check_units
decorator to detect errors from functions that have changed and add that information to the error message.Checklist