Open
Description
What happened?
Trying to package xarray 2024.11.0 in Mageia Caudron, I get this failure when running tests
Python 3.12
Numpy 2.1.0
Pandas 2.2.2
What did you expect to happen?
Test passes
Minimal Complete Verifiable Example
No response
MVCE confirmation
- Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- Complete example — the example is self-contained, including all data and the text of any traceback.
- Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
- New issue — a search of GitHub Issues suggests this is not a duplicate.
- Recent environment — the issue occurs with the latest version of xarray and its dependencies.
Relevant log output
=================================== FAILURES ===================================
________ TestMapOverSubTree.test_error_contains_path_of_offending_node _________
self = <xarray.tests.test_datatree_mapping.TestMapOverSubTree object at 0x7f009b68f8c0>
create_test_datatree = <function create_test_datatree.<locals>._create_test_datatree at 0x7f008eb9dbc0>
def test_error_contains_path_of_offending_node(self, create_test_datatree):
dt = create_test_datatree()
dt["set1"]["bad_var"] = 0
print(dt)
def fail_on_specific_node(ds):
if "bad_var" in ds:
raise ValueError("Failed because 'bar_var' present in dataset")
with pytest.raises(
ValueError,
match=re.escape(
r"Raised whilst mapping function over node with path 'set1'"
),
):
> dt.map_over_datasets(fail_on_specific_node)
/builddir/build/BUILD/python-xarray-2024.11.0-build/xarray-2024.11.0/xarray/tests/test_datatree_mapping.py:175:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/builddir/build/BUILD/python-xarray-2024.11.0-build/xarray-2024.11.0/xarray/core/datatree.py:1462: in map_over_datasets
return map_over_datasets(func, self, *args)
/builddir/build/BUILD/python-xarray-2024.11.0-build/xarray-2024.11.0/xarray/core/datatree_mapping.py:103: in map_over_datasets
results = func_with_error_context(*node_dataset_args)
/builddir/build/BUILD/python-xarray-2024.11.0-build/xarray-2024.11.0/xarray/core/datatree_mapping.py:133: in wrapper
return func(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
ds = <xarray.DatasetView> Size: 24B
Dimensions: ()
Data variables:
a int64 8B 0
b int64 8B 1
bad_var int64 8B 0
def fail_on_specific_node(ds):
if "bad_var" in ds:
> raise ValueError("Failed because 'bar_var' present in dataset")
E ValueError: Failed because 'bar_var' present in dataset
E Raised whilst mapping function over node with path 'set1'
/builddir/build/BUILD/python-xarray-2024.11.0-build/xarray-2024.11.0/xarray/tests/test_datatree_mapping.py:167: ValueError
During handling of the above exception, another exception occurred:
self = <xarray.tests.test_datatree_mapping.TestMapOverSubTree object at 0x7f009b68f8c0>
create_test_datatree = <function create_test_datatree.<locals>._create_test_datatree at 0x7f008eb9dbc0>
def test_error_contains_path_of_offending_node(self, create_test_datatree):
dt = create_test_datatree()
dt["set1"]["bad_var"] = 0
print(dt)
def fail_on_specific_node(ds):
if "bad_var" in ds:
raise ValueError("Failed because 'bar_var' present in dataset")
> with pytest.raises(
ValueError,
match=re.escape(
r"Raised whilst mapping function over node with path 'set1'"
),
):
E AssertionError: Regex pattern did not match.
E Regex: "Raised\\ whilst\\ mapping\\ function\\ over\\ node\\ with\\ path\\ 'set1'"
E Input: "Failed because 'bar_var' present in dataset"
/builddir/build/BUILD/python-xarray-2024.11.0-build/xarray-2024.11.0/xarray/tests/test_datatree_mapping.py:169: AssertionError
----------------------------- Captured stdout call -----------------------------
<xarray.DataTree>
Group: /
│ Dimensions: (y: 3, x: 2)
│ Dimensions without coordinates: y, x
│ Data variables:
│ a (y) int64 24B 6 7 8
│ set0 (x) int64 16B 9 10
├── Group: /set1
│ │ Dimensions: ()
│ │ Data variables:
│ │ a int64 8B 0
│ │ b int64 8B 1
│ │ bad_var int64 8B 0
│ ├── Group: /set1/set1
│ └── Group: /set1/set2
├── Group: /set2
│ │ Dimensions: (x: 2)
│ │ Dimensions without coordinates: x
│ │ Data variables:
│ │ a (x) int64 16B 2 3
│ │ b (x) float64 16B 0.1 0.2
│ └── Group: /set2/set1
└── Group: /set3
Anything else we need to know?
No response
Environment
Python 3.12
Numpy 2.1.0
Pandas 2.2.2