-
Notifications
You must be signed in to change notification settings - Fork 442
Open
Labels
Type: BugSomething is not working like it shouldSomething is not working like it should
Description
What went wrong?
Apparently MetPy is incompatible with the latest version of xarray (v2025.12.0).
See also #3977 and https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1123151.
Operating System
Linux
Version
1.7.1
Python Version
3.13
Code to Reproduce
$ python3.13 -m pytestErrors, Traceback, and Logs
============================= test session starts ==============================
platform linux -- Python 3.13.11, pytest-9.0.2, pluggy-1.6.0
Matplotlib: 3.10.7+dfsg1
Freetype: 2.13.3
Dep Versions: Cartopy: 0.25.0, Dask: 2024.12.1+dfsg, Matplotlib: 3.10.7+dfsg1,
Numpy: 2.3.5, Pandas: 2.3.3, Pint: 0.25.2, Pooch: v1.8.2, Pyproj: 3.7.2,
Scipy: 1.16.3, Shapely: 2.1.2, Traitlets: 5.14.3, Xarray: 2025.12.0
rootdir: /build/metpy-1.7.1+ds/.pybuild/cpython3_3.13_metpy/build
configfile: pyproject.toml
plugins: typeguard-4.4.4, mpl-0.17.0
collected 1354 items / 321 deselected / 1033 selected
tests/calc/test_basic.py ............................................... [ 4%]
........................................................................ [ 11%]
[CUT]
=================================== FAILURES ===================================
_______________________ test_absolute_momentum_given_xy ________________________
test_cross_xy = <xarray.Dataset> Size: 788B
Dimensions: (time: 1, isobaric: 5, index: 7)
Coordinates:
* time ...4....
v_wind (time, isobaric, index) float64 280B <Quantity([[[ 24....
lambert_conformal <U1 4B ''
def test_absolute_momentum_given_xy(test_cross_xy):
"""Test absolute momentum calculation."""
momentum = absolute_momentum(test_cross_xy['u_wind'], test_cross_xy['v_wind'])
true_momentum_values = np.array([[[169.22222693, 146.36354006, 145.75559124, 171.8710635,
215.04876817, 265.73797007, 318.34138347],
[156.27520858, 133.32107346, 132.62636169, 158.66828331,
201.78218117, 252.41370282, 304.96242462],
[143.32819023, 120.27860686, 119.49713214, 145.46550311,
188.51559418, 239.08943557, 291.58346576],
[130.38117188, 107.23614026, 106.36790259, 132.26272292,
175.24900718, 225.76516831, 278.20450691],
[117.43415353, 94.19367366, 93.23867305, 119.05994273,
161.98242018, 212.44090106, 264.82554806]]])
true_momentum = xr.DataArray(true_momentum_values * units('m/s'),
coords=test_cross_xy['u_wind'].coords,
dims=test_cross_xy['u_wind'].dims)
> assert_xarray_allclose(momentum, true_momentum)
tests/calc/test_cross_sections.py:323:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
actual = <xarray.DataArray (time: 1, isobaric: 5, index: 7)> Size: 280B
<Quantity([[[169.22221086 146.36352646 145.75557749 171...t64 56B -1.5e+06 -1.269e+06 ... -2.677e+05 -939.1
Attributes:
grid_mapping: lambert_conformal
_metpy_axis: x
desired = <xarray.DataArray (time: 1, isobaric: 5, index: 7)> Size: 280B
<Quantity([[[169.22222693 146.36354006 145.75559124 171...6B -4.995e+05 9.84e+04 ... 2.428e+06 3e+06
y (index) float64 56B -1.5e+06 -1.269e+06 ... -2.677e+05 -939.1
def assert_xarray_allclose(actual, desired):
"""Check that the xarrays are almost equal, including coordinates and attributes."""
xr.testing.assert_allclose(actual, desired)
assert desired.metpy.coordinates_identical(actual)
> assert desired.attrs == actual.attrs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E AssertionError
metpy/testing.py:328: AssertionError
_______________________ test_update_attribute_dictionary _______________________
test_ds_generic = <xarray.Dataset> Size: 2kB
Dimensions: (a: 1, b: 3, c: 3, d: 5, e: 5)
Coordinates:
* a (a) int64 8B 0
* b ...e) int64 40B 0 1 2 3 4
Data variables:
test (a, b, c, d, e) float64 2kB 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0
def test_update_attribute_dictionary(test_ds_generic):
"""Test update_attribute using dictionary."""
descriptions = {
'test': 'Filler data',
'c': 'The third coordinate'
}
test_ds_generic.c.attrs['units'] = 'K'
test_ds_generic.a.attrs['standard_name'] = 'air_temperature'
result = test_ds_generic.metpy.update_attribute('description', descriptions)
# Test attribute updates
assert 'description' not in result['a'].attrs
assert 'description' not in result['b'].attrs
assert result['c'].attrs['description'] == 'The third coordinate'
assert 'description' not in result['d'].attrs
assert 'description' not in result['e'].attrs
> assert result['test'].attrs['description'] == 'Filler data'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E KeyError: 'description'
tests/test_xarray.py:1116: KeyError
________________________ test_update_attribute_callable ________________________
test_ds_generic = <xarray.Dataset> Size: 2kB
Dimensions: (a: 1, b: 3, c: 3, d: 5, e: 5)
Coordinates:
* a (a) int64 8B 0
* b ...e) int64 40B 0 1 2 3 4
Data variables:
test (a, b, c, d, e) float64 2kB 0.0 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0 0.0
def test_update_attribute_callable(test_ds_generic):
"""Test update_attribute using callable."""
def even_ascii(varname, **kwargs):
return 'yes' if ord(varname[0]) % 2 == 0 else None
result = test_ds_generic.metpy.update_attribute('even', even_ascii)
# Test attribute updates
assert 'even' not in result['a'].attrs
assert result['b'].attrs['even'] == 'yes'
assert 'even' not in result['c'].attrs
assert result['d'].attrs['even'] == 'yes'
assert 'even' not in result['e'].attrs
> assert result['test'].attrs['even'] == 'yes'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E KeyError: 'even'
tests/test_xarray.py:1140: KeyError
=========================== short test summary info ============================
FAILED tests/calc/test_cross_sections.py::test_absolute_momentum_given_xy - A...
FAILED tests/test_xarray.py::test_update_attribute_dictionary - KeyError: 'de...
FAILED tests/test_xarray.py::test_update_attribute_callable - KeyError: 'even'
=============== 3 failed, 1030 passed, 321 deselected in 10.46s ================Metadata
Metadata
Assignees
Labels
Type: BugSomething is not working like it shouldSomething is not working like it should