Patch-Source: https://github.com/pydata/xarray/commit/a8c26200c533864e37e64fa282b1c2b188c78325 --- From a8c26200c533864e37e64fa282b1c2b188c78325 Mon Sep 17 00:00:00 2001 From: Julia Signell Date: Tue, 10 Mar 2026 14:21:39 -0400 Subject: [PATCH] Fix `TestDataArray.test_curvefit_helpers` and `TestIndexVariable.test_concat_periods` (#11204) * Filter deprecated warning * Remove inspect.signature raises error test. The example no longer raises an error * Type of error changed in numpy 2.4 --- xarray/core/utils.py | 4 ++-- xarray/tests/test_computation.py | 1 + xarray/tests/test_dataarray.py | 2 -- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/xarray/core/utils.py b/xarray/core/utils.py index c6828f0a363..100c256fa9d 100644 --- a/xarray/core/utils.py +++ b/xarray/core/utils.py @@ -205,7 +205,7 @@ def get_valid_numpy_dtype(array: np.ndarray | pd.Index) -> np.dtype: def maybe_coerce_to_str(index, original_coords): - """maybe coerce a pandas Index back to a nunpy array of type str + """maybe coerce a pandas Index back to a numpy array of type str pd.Index uses object-dtype to store str - try to avoid this for coords """ @@ -213,7 +213,7 @@ def maybe_coerce_to_str(index, original_coords): try: result_type = dtypes.result_type(*original_coords) - except TypeError: + except (TypeError, ValueError): pass else: if result_type.kind in "SU": diff --git a/xarray/tests/test_computation.py b/xarray/tests/test_computation.py index 84727cd210f..1cb8e6f4a3f 100644 --- a/xarray/tests/test_computation.py +++ b/xarray/tests/test_computation.py @@ -2646,6 +2646,7 @@ def test_complex_number_reduce(compute_backend): da.min() +@pytest.mark.filterwarnings("ignore:numpy.fix is deprecated.") def test_fix() -> None: val = 3.0 val_fixed = np.fix(val) diff --git a/xarray/tests/test_dataarray.py b/xarray/tests/test_dataarray.py index dc4c29d1a68..5e514cc9767 100644 --- a/xarray/tests/test_dataarray.py +++ b/xarray/tests/test_dataarray.py @@ -4908,8 +4908,6 @@ def exp_decay(t, n0, tau=1): param_names = ["a"] params, func_args = _get_func_args(np.power, param_names) assert params == param_names - with pytest.raises(ValueError): - _get_func_args(np.power, []) @requires_scipy @pytest.mark.parametrize("use_dask", [True, False])