-
Notifications
You must be signed in to change notification settings - Fork 415
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
Tests broken with updates to Pint constants and unit defaults #1115
Comments
Pint is simple enough to build that we could add installing pint from git to our existing set of dev builds. |
In trying to resolve the broken tests that are due to the changed pint constants, most can be fixed by adjusting the tolerances to less stringent, but still reasonable values. However, the geopotential <-> height conversion functions seem to be very sensitive to this change:
_________________________ test_height_to_geopotential __________________________
These mismatches seem about as bad as, if not worse than, the 32-bit destructive cancellation errors seen in #1075, for which specific strict-tolerance tests were implemented in #1082. What should be done about these? |
@jthielen Sounds like some digging into those calculations is needed. Are you just doing that by installing pint master, at least to reproduce those particular failures? |
Installing pint master is the easiest way to reproduce this set of failures, and that's how I produced the gist in the initial comment. (When I've been going through this, however, I've been using my A quick look back at the calculation shows that the only thing that appears to have changed is whereas in current pint master, it is If I alter the definition of G in G = units.Quantity(6.67384e-11, 'm^3 / kg / s^2') the geopotential <-> height conversion functions go back to passing. |
I am deeply disturbed by those tests failing, producing IMO large differences, due to a change in G in the 4th decimal place. |
This issue has reappeared with the continued updates to pint and MetPy's test suite. Right now (other than the infinite recursion with powers, which an upstream issue: hgrecco/pint#941, and the changes needed below), the following tests are failing:
There were two places where it was assumed that units were stripped, and now they are not. The following diff shows the basics of the changes needed: diff --git a/src/metpy/calc/thermo.py b/src/metpy/calc/thermo.py
index b7028aaa..fe0b706c 100644
--- a/src/metpy/calc/thermo.py
+++ b/src/metpy/calc/thermo.py
@@ -359,7 +359,7 @@ def lcl(pressure, temperature, dewpt, max_iters=50, eps=1e-5):
# np.isclose needed if surface is LCL due to precision error with np.log in dewpoint.
# Causes issues with parcel_profile_with_lcl if removed. Issue #1187
- lcl_p = np.where(np.isclose(lcl_p, pressure), pressure, lcl_p) * pressure.units
+ lcl_p = np.where(np.isclose(lcl_p, pressure.m), pressure.m, lcl_p) * pressure.units
return lcl_p, dewpoint(vapor_pressure(lcl_p, w)).to(temperature.units)
diff --git a/src/metpy/calc/tools.py b/src/metpy/calc/tools.py
index 7910c658..6507b0fa 100644
--- a/src/metpy/calc/tools.py
+++ b/src/metpy/calc/tools.py
@@ -777,6 +777,10 @@ def lat_lon_grid_deltas(longitude, latitude, **kwargs):
if latitude.ndim < 2:
longitude, latitude = np.meshgrid(longitude, latitude)
+ # pyproj requires ndarrays, not Quantities
+ longitude = np.asarray(longitude)
+ latitude = np.asarray(latitude)
+
geod_args = {'ellps': 'sphere'}
if kwargs:
geod_args = kwarg Although, on second thought, the When would it be best to get a PR for these in? |
@jthielen I think it'd be good to get one in for 0.12. Also, if we need any more discussion, probably best to do it in a follow-up issue since this one was already marked as closed in 0.11. |
So, I pointed my local Pint repo to the master branch instead of a tagged version or feature branch as I had been doing, and discovered that numerous tests are failing (see this gist)! Most are due calculations falling outside tolerance (which looks to be due to hgrecco/pint#811), but there is this particularly strange one
(link)
this one from a change of the default name for degrees Celsius
(link),
and one that was is skipped for 0.9 but isn't fixed yet in Pint (see hgrecco/pint#751)
(link).
I'm thinking most of these should be pretty straightforward to fix...but seeing all this after #997 and #1111 makes me think: is it possible to set up an allowed-failure CI build that tests against the master branch of pint to ensure these things get caught?
The text was updated successfully, but these errors were encountered: