Skip to content

Add support for Array API in NamedArray #233

Add support for Array API in NamedArray

Add support for Array API in NamedArray #233

GitHub Actions / Test Results failed Sep 24, 2024 in 0s

1 errors, 2 867 fail, 1 627 skipped, 15 758 pass in 53m 20s

      8 files  +      8       8 suites  +8   53m 20s ⏱️ + 53m 20s
 20 253 tests + 20 253  15 758 ✅ +15 758   1 627 💤 + 1 627  2 867 ❌ +2 867  1 🔥 +1 
123 368 runs  +123 368  98 443 ✅ +98 443  17 740 💤 +17 740  7 181 ❌ +7 181  4 🔥 +4 

Results for commit 733a45a. ± Comparison against earlier commit 842b289.

Annotations

Check warning on line 0 in xarray.tests.test_array_api

See this annotation in the file changed.

@github-actions github-actions / Test Results

4 out of 6 runs failed: test_aggregation (xarray.tests.test_array_api)

artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
Raw output
ValueError: x must be at least 2-dimensional for matrix_transpose
arrays = (<xarray.DataArray (x: 2, y: 3)> Size: 48B
array([[ 1.,  2.,  3.],
       [ 4.,  5., nan]])
Coordinates:
  * x        ...nan]], dtype=array_api_strict.float64)
Coordinates:
  * x        (x) int64 16B 10 20
Dimensions without coordinates: y)

    def test_aggregation(arrays: tuple[xr.DataArray, xr.DataArray]) -> None:
        np_arr, xp_arr = arrays
        expected = np_arr.sum()
>       actual = xp_arr.sum()

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_array_api.py#x1B[0m:41: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1857: in sum
    return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3837: in reduce
    var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1678: in reduce
    result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1396: in reduce
    return from_array(dims, data, attrs=self._attrs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:212: in from_array
    if isinstance(data, _arrayfunction_or_api):
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/typing.py#x1B[0m:1506: in __instancecheck__
    if all(hasattr(instance, attr) and
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/typing.py#x1B[0m:1506: in <genexpr>
    if all(hasattr(instance, attr) and
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/array_api_strict/_array_object.py#x1B[0m:1178: in mT
    return matrix_transpose(self)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

x = Array(15., dtype=array_api_strict.float64)

    def matrix_transpose(x: Array, /) -> Array:
        if x.ndim < 2:
>           raise ValueError("x must be at least 2-dimensional for matrix_transpose")
#x1B[1m#x1B[31mE           ValueError: x must be at least 2-dimensional for matrix_transpose#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/array_api_strict/_linear_algebra_functions.py#x1B[0m:50: ValueError

Check warning on line 0 in xarray.tests.test_array_api

See this annotation in the file changed.

@github-actions github-actions / Test Results

4 out of 6 runs failed: test_aggregation_skipna (xarray.tests.test_array_api)

artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
Raw output
ValueError: x must be at least 2-dimensional for matrix_transpose
arrays = (<xarray.DataArray (x: 2, y: 3)> Size: 48B
array([[ 1.,  2.,  3.],
       [ 4.,  5., nan]])
Coordinates:
  * x        ...nan]], dtype=array_api_strict.float64)
Coordinates:
  * x        (x) int64 16B 10 20
Dimensions without coordinates: y)

    def test_aggregation_skipna(arrays) -> None:
        np_arr, xp_arr = arrays
        expected = np_arr.sum(skipna=False)
>       actual = xp_arr.sum(skipna=False)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_array_api.py#x1B[0m:49: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1857: in sum
    return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3837: in reduce
    var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1678: in reduce
    result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1396: in reduce
    return from_array(dims, data, attrs=self._attrs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:212: in from_array
    if isinstance(data, _arrayfunction_or_api):
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/typing.py#x1B[0m:1506: in __instancecheck__
    if all(hasattr(instance, attr) and
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/typing.py#x1B[0m:1506: in <genexpr>
    if all(hasattr(instance, attr) and
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/array_api_strict/_array_object.py#x1B[0m:1178: in mT
    return matrix_transpose(self)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

x = Array(nan, dtype=array_api_strict.float64)

    def matrix_transpose(x: Array, /) -> Array:
        if x.ndim < 2:
>           raise ValueError("x must be at least 2-dimensional for matrix_transpose")
#x1B[1m#x1B[31mE           ValueError: x must be at least 2-dimensional for matrix_transpose#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/array_api_strict/_linear_algebra_functions.py#x1B[0m:50: ValueError

Check warning on line 0 in xarray.tests.test_assertions

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 7 runs failed: test_assert_allclose[Dataset] (xarray.tests.test_assertions)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool_'?
obj1 = <xarray.Dataset> Size: 32B
Dimensions:  (x: 2, y: 2)
Dimensions without coordinates: x, y
Data variables:
    a        (x) float64 16B 1e-17 2.0
    b        (y) float64 16B -2e-18 2.0
obj2 = <xarray.Dataset> Size: 32B
Dimensions:  (x: 2, y: 2)
Dimensions without coordinates: x, y
Data variables:
    a        (x) int64 16B 0 2
    b        (y) int64 16B 0 1

    @pytest.mark.parametrize(
        "obj1,obj2",
        (
            pytest.param(
                xr.Variable("x", [1e-17, 2]), xr.Variable("x", [0, 3]), id="Variable"
            ),
            pytest.param(
                xr.DataArray([1e-17, 2], dims="x"),
                xr.DataArray([0, 3], dims="x"),
                id="DataArray",
            ),
            pytest.param(
                xr.Dataset({"a": ("x", [1e-17, 2]), "b": ("y", [-2e-18, 2])}),
                xr.Dataset({"a": ("x", [0, 2]), "b": ("y", [0, 1])}),
                id="Dataset",
            ),
            pytest.param(
                xr.DataArray(np.array("a", dtype="|S1")),
                xr.DataArray(np.array("b", dtype="|S1")),
                id="DataArray_with_character_dtype",
            ),
        ),
    )
    def test_assert_allclose(obj1, obj2) -> None:
        with pytest.raises(AssertionError):
>           xr.testing.assert_allclose(obj1, obj2)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_assertions.py#x1B[0m:64: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/formatting.py#x1B[0m:1025: in diff_dataset_repr
    diff_data_vars_repr(a.data_vars, b.data_vars, compat, col_width=col_width)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/formatting.py#x1B[0m:858: in _diff_mapping_repr
    summarizer(k, a_mapping[k], col_width, **a_summarizer_kwargs[k]),
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/formatting.py#x1B[0m:345: in summarize_variable
    nbytes_str = f" {render_human_readable_nbytes(variable.nbytes)}"
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:925: in nbytes
    from xarray.namedarray._array_api._utils import _get_data_namespace
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
            warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
    
        if attr in __former_attrs__:
>           raise AttributeError(__former_attrs__[attr])
#x1B[1m#x1B[31mE           AttributeError: module 'numpy' has no attribute 'bool'.#x1B[0m
#x1B[1m#x1B[31mE           `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.#x1B[0m
#x1B[1m#x1B[31mE           The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:#x1B[0m
#x1B[1m#x1B[31mE               https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool_'?#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:305: AttributeError

Check warning on line 0 in xarray.tests.test_assertions

See this annotation in the file changed.

@github-actions github-actions / Test Results

2 out of 7 runs failed: test_ensure_warnings_not_elevated[assert_duckarray_equal] (xarray.tests.test_assertions)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
Raw output
AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool_'?
func = 'assert_duckarray_equal'

    @pytest.mark.parametrize(
        "func",
        [
            "assert_equal",
            "assert_identical",
            "assert_allclose",
            "assert_duckarray_equal",
            "assert_duckarray_allclose",
        ],
    )
    def test_ensure_warnings_not_elevated(func) -> None:
        # make sure warnings are not elevated to errors in the assertion functions
        # e.g. by @pytest.mark.filterwarnings("error")
        # see https://github.com/pydata/xarray/pull/4760#issuecomment-774101639
    
        # define a custom Variable class that raises a warning in assert_*
        class WarningVariable(xr.Variable):
            @property  # type: ignore[misc]
            def dims(self):
                warnings.warn("warning in test", stacklevel=2)
                return super().dims
    
            def __array__(self, dtype=None, copy=None):
                warnings.warn("warning in test", stacklevel=2)
                return super().__array__()
    
        a = WarningVariable("x", [1])
        b = WarningVariable("x", [2])
    
        with warnings.catch_warnings(record=True) as w:
            # elevate warnings to errors
            warnings.filterwarnings("error")
            with pytest.raises(AssertionError):
>               getattr(xr.testing, func)(a, b)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_assertions.py#x1B[0m:187: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:314: in array_equiv
    flag_array = (arr1 == arr2) | (isnull(arr1) & isnull(arr2))
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:137: in isnull
    xp = get_array_namespace(data)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:65: in get_array_namespace
    namespaces = {_get_array_namespace(t) for t in values}
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:65: in <setcomp>
    namespaces = {_get_array_namespace(t) for t in values}
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:61: in _get_array_namespace
    return x.__array_namespace__()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:462: in __array_namespace__
    import xarray.namedarray._array_api as array_api
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
            warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
    
        if attr in __former_attrs__:
>           raise AttributeError(__former_attrs__[attr])
#x1B[1m#x1B[31mE           AttributeError: module 'numpy' has no attribute 'bool'.#x1B[0m
#x1B[1m#x1B[31mE           `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.#x1B[0m
#x1B[1m#x1B[31mE           The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:#x1B[0m
#x1B[1m#x1B[31mE               https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool_'?#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:305: AttributeError

Check warning on line 0 in xarray.tests.test_computation

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 7 runs failed: test_apply_missing_dims (xarray.tests.test_computation)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
def test_apply_missing_dims() -> None:
        ## Single arg
    
        def add_one(a, core_dims, on_missing_core_dim):
            return apply_ufunc(
                lambda x: x + 1,
                a,
                input_core_dims=core_dims,
                output_core_dims=core_dims,
                on_missing_core_dim=on_missing_core_dim,
            )
    
        array = np.arange(6).reshape(2, 3)
        variable = xr.Variable(["x", "y"], array)
        variable_no_y = xr.Variable(["x", "z"], array)
    
        ds = xr.Dataset({"x_y": variable, "x_z": variable_no_y})
    
        # Check the standard stuff works OK
        assert_identical(
            add_one(ds[["x_y"]], core_dims=[["y"]], on_missing_core_dim="raise"),
            ds[["x_y"]] + 1,
        )
    
        # `raise` — should raise on a missing dim
        with pytest.raises(ValueError):
>           add_one(ds, core_dims=[["y"]], on_missing_core_dim="raise")

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_computation.py#x1B[0m:286: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_computation.py#x1B[0m:264: in add_one
    return apply_ufunc(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/computation.py#x1B[0m:1265: in apply_ufunc
    return apply_dataset_vfunc(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/computation.py#x1B[0m:536: in apply_dataset_vfunc
    result_vars = apply_dict_of_variables_vfunc(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/computation.py#x1B[0m:458: in apply_dict_of_variables_vfunc
    core_dim_present = _check_core_dims(signature, variable_args, name)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/computation.py#x1B[0m:435: in _check_core_dims
    message += f"Missing core dims {set(core_dims) - set(variable_arg.dims)} from arg number {i + 1} on a variable named `{name}`:\n{variable_arg}\n\n"
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/common.py#x1B[0m:205: in __format__
    return self.__repr__()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/common.py#x1B[0m:183: in __repr__
    return formatting.array_repr(self)
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/reprlib.py#x1B[0m:21: in wrapper
    result = user_function(self)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/formatting.py#x1B[0m:698: in array_repr
    nbytes_str = render_human_readable_nbytes(arr.nbytes)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:925: in nbytes
    from xarray.namedarray._array_api._utils import _get_data_namespace
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
>           warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
#x1B[1m#x1B[31mE           FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:300: FutureWarning

Check warning on line 0 in xarray.tests.test_dataset.TestDataset

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 7 runs failed: test_copy_coords[False-expected_orig1] (xarray.tests.test_dataset.TestDataset)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool_'?
self = <xarray.tests.test_dataset.TestDataset object at 0x7f2095620b50>
deep = False
expected_orig = <xarray.DataArray 'a' (a: 2)> Size: 16B
array([999,   2])
Coordinates:
  * a        (a) int64 16B 999 2

    @pytest.mark.xfail(raises=AssertionError)
    @pytest.mark.parametrize(
        "deep, expected_orig",
        [
            [
                True,
                xr.DataArray(
                    xr.IndexVariable("a", np.array([1, 2])),
                    coords={"a": [1, 2]},
                    dims=["a"],
                ),
            ],
            [
                False,
                xr.DataArray(
                    xr.IndexVariable("a", np.array([999, 2])),
                    coords={"a": [999, 2]},
                    dims=["a"],
                ),
            ],
        ],
    )
    def test_copy_coords(self, deep, expected_orig) -> None:
        """The test fails for the shallow copy, and apparently only on Windows
        for some reason. In windows coords seem to be immutable unless it's one
        dataset deep copied from another."""
        ds = xr.DataArray(
            np.ones([2, 2, 2]),
            coords={"a": [1, 2], "b": ["x", "y"], "c": [0, 1]},
            dims=["a", "b", "c"],
            name="value",
        ).to_dataset()
        ds_cp = ds.copy(deep=deep)
        new_a = np.array([999, 2])
        ds_cp.coords["a"] = ds_cp.a.copy(data=new_a)
    
        expected_cp = xr.DataArray(
            xr.IndexVariable("a", new_a),
            coords={"a": [999, 2]},
            dims=["a"],
        )
        assert_identical(ds_cp.coords["a"], expected_cp)
    
>       assert_identical(ds.coords["a"], expected_orig)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_dataset.py#x1B[0m:3024: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/formatting.py#x1B[0m:975: in diff_array_repr
    diff_coords_repr(a.coords, b.coords, compat, col_width=col_width)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/formatting.py#x1B[0m:918: in diff_coords_repr
    return _diff_mapping_repr(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/formatting.py#x1B[0m:858: in _diff_mapping_repr
    summarizer(k, a_mapping[k], col_width, **a_summarizer_kwargs[k]),
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/formatting.py#x1B[0m:345: in summarize_variable
    nbytes_str = f" {render_human_readable_nbytes(variable.nbytes)}"
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:925: in nbytes
    from xarray.namedarray._array_api._utils import _get_data_namespace
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
            warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
    
        if attr in __former_attrs__:
>           raise AttributeError(__former_attrs__[attr])
#x1B[1m#x1B[31mE           AttributeError: module 'numpy' has no attribute 'bool'.#x1B[0m
#x1B[1m#x1B[31mE           `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.#x1B[0m
#x1B[1m#x1B[31mE           The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:#x1B[0m
#x1B[1m#x1B[31mE               https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool_'?#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:305: AttributeError

Check warning on line 0 in xarray.tests.test_namedarray.TestNamedArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

All 7 runs failed: test_from_array_with_explicitly_indexed (xarray.tests.test_namedarray.TestNamedArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
artifacts/Test results for macOS-3.12/pytest.xml [took 0s]
Raw output
AssertionError: assert False
 +  where False = isinstance(array([[[ 0.,  1.,  2.,  3.,  4.],\n        [ 5.,  6.,  7.,  8.,  9.],\n        [10., 11., 12., 13., 14.],\n        [15.,...      [45., 46., 47., 48., 49.],\n        [50., 51., 52., 53., 54.],\n        [55., 56., 57., 58., 59.]]], dtype=float32), CustomArrayIndexable)
 +    where array([[[ 0.,  1.,  2.,  3.,  4.],\n        [ 5.,  6.,  7.,  8.,  9.],\n        [10., 11., 12., 13., 14.],\n        [15.,...      [45., 46., 47., 48., 49.],\n        [50., 51., 52., 53., 54.],\n        [55., 56., 57., 58., 59.]]], dtype=float32) = <Namedarray, shape=(3, 4, 5), dims=('x', 'y', 'z'), dtype=float32, data=[[[ 0.  1.  2.  3.  4.]\n  [ 5.  6.  7.  8.  9..... 36. 37. 38. 39.]]\n\n [[40. 41. 42. 43. 44.]\n  [45. 46. 47. 48. 49.]\n  [50. 51. 52. 53. 54.]\n  [55. 56. 57. 58. 59.]]]>.data
self = <xarray.tests.test_namedarray.TestNamedArray object at 0x7f84105bca10>
random_inputs = array([[[ 0.,  1.,  2.,  3.,  4.],
        [ 5.,  6.,  7.,  8.,  9.],
        [10., 11., 12., 13., 14.],
        [15.,...      [45., 46., 47., 48., 49.],
        [50., 51., 52., 53., 54.],
        [55., 56., 57., 58., 59.]]], dtype=float32)

    def test_from_array_with_explicitly_indexed(
        self, random_inputs: np.ndarray[Any, Any]
    ) -> None:
        array: CustomArray[Any, Any]
        array = CustomArray(random_inputs)
        output: NamedArray[Any, Any]
        output = from_array(("x", "y", "z"), array)
        assert isinstance(output.data, np.ndarray)
    
        array2: CustomArrayIndexable[Any, Any]
        array2 = CustomArrayIndexable(random_inputs)
        output2: NamedArray[Any, Any]
        output2 = from_array(("x", "y", "z"), array2)
>       assert isinstance(output2.data, CustomArrayIndexable)
#x1B[1m#x1B[31mE       AssertionError: assert False#x1B[0m
#x1B[1m#x1B[31mE        +  where False = isinstance(array([[[ 0.,  1.,  2.,  3.,  4.],\n        [ 5.,  6.,  7.,  8.,  9.],\n        [10., 11., 12., 13., 14.],\n        [15.,...      [45., 46., 47., 48., 49.],\n        [50., 51., 52., 53., 54.],\n        [55., 56., 57., 58., 59.]]], dtype=float32), CustomArrayIndexable)#x1B[0m
#x1B[1m#x1B[31mE        +    where array([[[ 0.,  1.,  2.,  3.,  4.],\n        [ 5.,  6.,  7.,  8.,  9.],\n        [10., 11., 12., 13., 14.],\n        [15.,...      [45., 46., 47., 48., 49.],\n        [50., 51., 52., 53., 54.],\n        [55., 56., 57., 58., 59.]]], dtype=float32) = <Namedarray, shape=(3, 4, 5), dims=('x', 'y', 'z'), dtype=float32, data=[[[ 0.  1.  2.  3.  4.]\n  [ 5.  6.  7.  8.  9..... 36. 37. 38. 39.]]\n\n [[40. 41. 42. 43. 44.]\n  [45. 46. 47. 48. 49.]\n  [50. 51. 52. 53. 54.]\n  [55. 56. 57. 58. 59.]]]>.data#x1B[0m

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_namedarray.py#x1B[0m:258: AssertionError

Check warning on line 0 in xarray.tests.test_namedarray.TestNamedArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

3 out of 7 runs failed: test_real_and_imag (xarray.tests.test_namedarray.TestNamedArray)

artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
Raw output
ValueError: matrix transpose with ndim < 2 is undefined
self = <xarray.tests.test_namedarray.TestNamedArray object at 0x7f4d98562380>

    def test_real_and_imag(self) -> None:
        expected_real: np.ndarray[Any, np.dtype[np.float64]]
        expected_real = np.arange(3, dtype=np.float64)
    
        expected_imag: np.ndarray[Any, np.dtype[np.float64]]
        expected_imag = -np.arange(3, dtype=np.float64)
    
        arr: np.ndarray[Any, np.dtype[np.complex128]]
        arr = expected_real + 1j * expected_imag
    
        named_array: NamedArray[Any, np.dtype[np.complex128]]
        named_array = NamedArray(["x"], arr)
    
>       actual_real: duckarray[Any, np.dtype[np.float64]] = named_array.real.data

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_namedarray.py#x1B[0m:273: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1038: in real
    if isinstance(self._data, _arrayapi):
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/typing.py#x1B[0m:1506: in __instancecheck__
    if all(hasattr(instance, attr) and
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

.0 = <set_iterator object at 0x7f4d7ab7b3c0>

>   if all(hasattr(instance, attr) and
            # All *methods* can be blocked by setting them to None.
            (not callable(getattr(cls, attr, None)) or
             getattr(instance, attr) is not None)
            for attr in _get_protocol_attrs(cls)):
#x1B[1m#x1B[31mE           ValueError: matrix transpose with ndim < 2 is undefined#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/typing.py#x1B[0m:1506: ValueError

Check warning on line 0 in xarray.tests.test_namedarray.TestNamedArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

All 7 runs failed: test_duck_array_class (xarray.tests.test_namedarray.TestNamedArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
artifacts/Test results for macOS-3.12/pytest.xml [took 0s]
Raw output
TypeError: a (<class 'xarray.tests.test_namedarray.CustomArrayIndexable'>) is not a valid _arrayfunction or _arrayapi. Missing following attrs:
_arrayfunction - {'imag', '__array_ufunc__', '__array_function__', 'real'}
_arrayapi - {'mT', 'to_device', 'device'}
self = <xarray.tests.test_namedarray.TestNamedArray object at 0x7f84105d2db0>

    def test_duck_array_class(self) -> None:
        numpy_a: NDArray[np.int64]
        numpy_a = np.array([2.1, 4], dtype=np.dtype(np.int64))
        check_duck_array_typevar(numpy_a)
    
        masked_a: np.ma.MaskedArray[Any, np.dtype[np.int64]]
        masked_a = np.ma.asarray([2.1, 4], dtype=np.dtype(np.int64))  # type: ignore[no-untyped-call]
        check_duck_array_typevar(masked_a)
    
        custom_a: CustomArrayIndexable[Any, np.dtype[np.int64]]
        custom_a = CustomArrayIndexable(numpy_a)
>       check_duck_array_typevar(custom_a)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_namedarray.py#x1B[0m:375: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

a = <xarray.tests.test_namedarray.CustomArrayIndexable object at 0x7f83f087cf50>

    def check_duck_array_typevar(a: duckarray[Any, _DType]) -> duckarray[Any, _DType]:
        # Mypy checks a is valid:
        b: duckarray[Any, _DType] = a
    
        # Runtime check if valid:
        if isinstance(b, _arrayfunction_or_api):
            return b
        else:
            missing_attrs = ""
            actual_attrs = set(dir(b))
            for t in _arrayfunction_or_api:
                if sys.version_info >= (3, 13):
                    # https://github.com/python/cpython/issues/104873
                    from typing import get_protocol_members
    
                    expected_attrs = get_protocol_members(t)
                elif sys.version_info >= (3, 12):
                    expected_attrs = t.__protocol_attrs__
                else:
                    from typing import _get_protocol_attrs  # type: ignore[attr-defined]
    
                    expected_attrs = _get_protocol_attrs(t)
    
                missing_attrs_ = expected_attrs - actual_attrs
                if missing_attrs_:
                    missing_attrs += f"{t.__name__} - {missing_attrs_}\n"
>           raise TypeError(
                f"a ({type(a)}) is not a valid _arrayfunction or _arrayapi. "
                "Missing following attrs:\n"
                f"{missing_attrs}"
            )
#x1B[1m#x1B[31mE           TypeError: a (<class 'xarray.tests.test_namedarray.CustomArrayIndexable'>) is not a valid _arrayfunction or _arrayapi. Missing following attrs:#x1B[0m
#x1B[1m#x1B[31mE           _arrayfunction - {'imag', '__array_ufunc__', '__array_function__', 'real'}#x1B[0m
#x1B[1m#x1B[31mE           _arrayapi - {'mT', 'to_device', 'device'}#x1B[0m

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_namedarray.py#x1B[0m:108: TypeError

Check warning on line 0 in xarray.tests.test_namedarray.TestNamedArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

4 out of 7 runs failed: test_duck_array_class_array_api (xarray.tests.test_namedarray.TestNamedArray)

artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
Raw output
ValueError: x must be at least 2-dimensional for matrix_transpose
self = <xarray.tests.test_namedarray.TestNamedArray object at 0x7f4d98560100>

    def test_duck_array_class_array_api(self) -> None:
        # Test numpy's array api:
        nxp = pytest.importorskip("array_api_strict", minversion="1.0")
    
        # TODO: nxp doesn't use dtype typevars, so can only use Any for the moment:
        arrayapi_a: duckarray[Any, Any]  #  duckarray[Any, np.dtype[np.int64]]
        arrayapi_a = nxp.asarray([2.1, 4], dtype=nxp.int64)
>       check_duck_array_typevar(arrayapi_a)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_namedarray.py#x1B[0m:384: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_namedarray.py#x1B[0m:87: in check_duck_array_typevar
    if isinstance(b, _arrayfunction_or_api):
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/typing.py#x1B[0m:1506: in __instancecheck__
    if all(hasattr(instance, attr) and
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/typing.py#x1B[0m:1506: in <genexpr>
    if all(hasattr(instance, attr) and
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/array_api_strict/_array_object.py#x1B[0m:1178: in mT
    return matrix_transpose(self)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

x = Array([2, 4], dtype=array_api_strict.int64)

    def matrix_transpose(x: Array, /) -> Array:
        if x.ndim < 2:
>           raise ValueError("x must be at least 2-dimensional for matrix_transpose")
#x1B[1m#x1B[31mE           ValueError: x must be at least 2-dimensional for matrix_transpose#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/array_api_strict/_linear_algebra_functions.py#x1B[0m:50: ValueError

Check warning on line 0 in xarray.tests.test_namedarray.TestNamedArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

2 out of 7 runs failed: test_expand_dims[None-3-expected_shape0-expected_dims0] (xarray.tests.test_namedarray.TestNamedArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
Raw output
FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
self = <xarray.tests.test_namedarray.TestNamedArray object at 0x7f1d54fc5660>
target = <Namedarray, shape=(2, 5), dims=('x', 'y'), dtype=float64, data=[[0.  0.5 1.  1.5 2. ]
 [2.5 3.  3.5 4.  4.5]]>
dim = None, expected_ndim = 3, expected_shape = (1, 2, 5)
expected_dims = (None, 'x', 'y')

    @pytest.mark.parametrize(
        "dim,expected_ndim,expected_shape,expected_dims",
        [
            (None, 3, (1, 2, 5), (None, "x", "y")),
            (_default, 3, (1, 2, 5), ("dim_2", "x", "y")),
            ("z", 3, (1, 2, 5), ("z", "x", "y")),
        ],
    )
    def test_expand_dims(
        self,
        target: NamedArray[Any, np.dtype[np.float32]],
        dim: _Dim | Default,
        expected_ndim: int,
        expected_shape: _ShapeLike,
        expected_dims: _DimsLike,
    ) -> None:
>       result = target.expand_dims(dim=dim)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_namedarray.py#x1B[0m:520: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1593: in expand_dims
    from xarray.namedarray._array_api import expand_dims
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
>           warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
#x1B[1m#x1B[31mE           FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:300: FutureWarning

Check warning on line 0 in xarray.tests.test_namedarray.TestNamedArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

2 out of 7 runs failed: test_expand_dims[dim1-3-expected_shape1-expected_dims1] (xarray.tests.test_namedarray.TestNamedArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
Raw output
FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
self = <xarray.tests.test_namedarray.TestNamedArray object at 0x7f1d54fc6f80>
target = <Namedarray, shape=(2, 5), dims=('x', 'y'), dtype=float64, data=[[0.  0.5 1.  1.5 2. ]
 [2.5 3.  3.5 4.  4.5]]>
dim = <Default>, expected_ndim = 3, expected_shape = (1, 2, 5)
expected_dims = ('dim_2', 'x', 'y')

    @pytest.mark.parametrize(
        "dim,expected_ndim,expected_shape,expected_dims",
        [
            (None, 3, (1, 2, 5), (None, "x", "y")),
            (_default, 3, (1, 2, 5), ("dim_2", "x", "y")),
            ("z", 3, (1, 2, 5), ("z", "x", "y")),
        ],
    )
    def test_expand_dims(
        self,
        target: NamedArray[Any, np.dtype[np.float32]],
        dim: _Dim | Default,
        expected_ndim: int,
        expected_shape: _ShapeLike,
        expected_dims: _DimsLike,
    ) -> None:
>       result = target.expand_dims(dim=dim)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_namedarray.py#x1B[0m:520: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1593: in expand_dims
    from xarray.namedarray._array_api import expand_dims
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
>           warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
#x1B[1m#x1B[31mE           FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:300: FutureWarning

Check warning on line 0 in xarray.tests.test_namedarray.TestNamedArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

2 out of 7 runs failed: test_expand_dims[z-3-expected_shape2-expected_dims2] (xarray.tests.test_namedarray.TestNamedArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
Raw output
FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
self = <xarray.tests.test_namedarray.TestNamedArray object at 0x7f1d54fc7d60>
target = <Namedarray, shape=(2, 5), dims=('x', 'y'), dtype=float64, data=[[0.  0.5 1.  1.5 2. ]
 [2.5 3.  3.5 4.  4.5]]>
dim = 'z', expected_ndim = 3, expected_shape = (1, 2, 5)
expected_dims = ('z', 'x', 'y')

    @pytest.mark.parametrize(
        "dim,expected_ndim,expected_shape,expected_dims",
        [
            (None, 3, (1, 2, 5), (None, "x", "y")),
            (_default, 3, (1, 2, 5), ("dim_2", "x", "y")),
            ("z", 3, (1, 2, 5), ("z", "x", "y")),
        ],
    )
    def test_expand_dims(
        self,
        target: NamedArray[Any, np.dtype[np.float32]],
        dim: _Dim | Default,
        expected_ndim: int,
        expected_shape: _ShapeLike,
        expected_dims: _DimsLike,
    ) -> None:
>       result = target.expand_dims(dim=dim)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_namedarray.py#x1B[0m:520: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1593: in expand_dims
    from xarray.namedarray._array_api import expand_dims
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
>           warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
#x1B[1m#x1B[31mE           FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:300: FutureWarning

Check warning on line 0 in xarray.tests.test_namedarray.TestNamedArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

2 out of 7 runs failed: test_permute_dims[dims0-expected_sizes0] (xarray.tests.test_namedarray.TestNamedArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
Raw output
FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
self = <xarray.tests.test_namedarray.TestNamedArray object at 0x7f1d54fc7850>
target = <Namedarray, shape=(2, 5), dims=('x', 'y'), dtype=float64, data=[[0.  0.5 1.  1.5 2. ]
 [2.5 3.  3.5 4.  4.5]]>
dims = (), expected_sizes = {'x': 2, 'y': 5}

    @pytest.mark.parametrize(
        "dims, expected_sizes",
        [
            ((), {"y": 5, "x": 2}),
            (["y", "x"], {"y": 5, "x": 2}),
            (["y", ...], {"y": 5, "x": 2}),
        ],
    )
    def test_permute_dims(
        self,
        target: NamedArray[Any, np.dtype[np.float32]],
        dims: _DimsLike,
        expected_sizes: dict[_Dim, _IntOrUnknown],
    ) -> None:
>       actual = target.permute_dims(*dims)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_namedarray.py#x1B[0m:539: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1487: in permute_dims
    from xarray.namedarray._array_api import permute_dims
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
>           warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
#x1B[1m#x1B[31mE           FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:300: FutureWarning

Check warning on line 0 in xarray.tests.test_namedarray.TestNamedArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

2 out of 7 runs failed: test_permute_dims[dims1-expected_sizes1] (xarray.tests.test_namedarray.TestNamedArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
Raw output
FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
self = <xarray.tests.test_namedarray.TestNamedArray object at 0x7f1d54fc7370>
target = <Namedarray, shape=(2, 5), dims=('x', 'y'), dtype=float64, data=[[0.  0.5 1.  1.5 2. ]
 [2.5 3.  3.5 4.  4.5]]>
dims = ['y', 'x'], expected_sizes = {'x': 2, 'y': 5}

    @pytest.mark.parametrize(
        "dims, expected_sizes",
        [
            ((), {"y": 5, "x": 2}),
            (["y", "x"], {"y": 5, "x": 2}),
            (["y", ...], {"y": 5, "x": 2}),
        ],
    )
    def test_permute_dims(
        self,
        target: NamedArray[Any, np.dtype[np.float32]],
        dims: _DimsLike,
        expected_sizes: dict[_Dim, _IntOrUnknown],
    ) -> None:
>       actual = target.permute_dims(*dims)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_namedarray.py#x1B[0m:539: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1487: in permute_dims
    from xarray.namedarray._array_api import permute_dims
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
>           warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
#x1B[1m#x1B[31mE           FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:300: FutureWarning

Check warning on line 0 in xarray.tests.test_namedarray.TestNamedArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

2 out of 7 runs failed: test_permute_dims[dims2-expected_sizes2] (xarray.tests.test_namedarray.TestNamedArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
Raw output
FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
self = <xarray.tests.test_namedarray.TestNamedArray object at 0x7f1d54fc7f40>
target = <Namedarray, shape=(2, 5), dims=('x', 'y'), dtype=float64, data=[[0.  0.5 1.  1.5 2. ]
 [2.5 3.  3.5 4.  4.5]]>
dims = ['y', Ellipsis], expected_sizes = {'x': 2, 'y': 5}

    @pytest.mark.parametrize(
        "dims, expected_sizes",
        [
            ((), {"y": 5, "x": 2}),
            (["y", "x"], {"y": 5, "x": 2}),
            (["y", ...], {"y": 5, "x": 2}),
        ],
    )
    def test_permute_dims(
        self,
        target: NamedArray[Any, np.dtype[np.float32]],
        dims: _DimsLike,
        expected_sizes: dict[_Dim, _IntOrUnknown],
    ) -> None:
>       actual = target.permute_dims(*dims)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_namedarray.py#x1B[0m:539: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1487: in permute_dims
    from xarray.namedarray._array_api import permute_dims
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
>           warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
#x1B[1m#x1B[31mE           FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:300: FutureWarning

Check warning on line 0 in xarray.tests.test_namedarray.TestNamedArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

2 out of 7 runs failed: test_permute_dims_errors (xarray.tests.test_namedarray.TestNamedArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
Raw output
FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
self = <xarray.tests.test_namedarray.TestNamedArray object at 0x7f1d54fc79d0>
target = <Namedarray, shape=(2, 5), dims=('x', 'y'), dtype=float64, data=[[0.  0.5 1.  1.5 2. ]
 [2.5 3.  3.5 4.  4.5]]>

    def test_permute_dims_errors(
        self,
        target: NamedArray[Any, np.dtype[np.float32]],
    ) -> None:
        with pytest.raises(ValueError, match=r"'y'.*permuted list"):
            dims = ["y"]
>           target.permute_dims(*dims)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_namedarray.py#x1B[0m:548: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1487: in permute_dims
    from xarray.namedarray._array_api import permute_dims
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
>           warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
#x1B[1m#x1B[31mE           FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:300: FutureWarning

Check warning on line 0 in xarray.tests.test_namedarray.TestNamedArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

2 out of 7 runs failed: test_broadcast_to[broadcast_dims1-3] (xarray.tests.test_namedarray.TestNamedArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
Raw output
FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
self = <xarray.tests.test_namedarray.TestNamedArray object at 0x7f1d54fc70a0>
target = <Namedarray, shape=(2, 5), dims=('x', 'y'), dtype=float64, data=[[0.  0.5 1.  1.5 2. ]
 [2.5 3.  3.5 4.  4.5]]>
broadcast_dims = {'x': 2, 'y': 5, 'z': 2}, expected_ndim = 3

    @pytest.mark.parametrize(
        "broadcast_dims,expected_ndim",
        [
            ({"x": 2, "y": 5}, 2),
            ({"x": 2, "y": 5, "z": 2}, 3),
            ({"w": 1, "x": 2, "y": 5}, 3),
        ],
    )
    def test_broadcast_to(
        self,
        target: NamedArray[Any, np.dtype[np.float32]],
        broadcast_dims: Mapping[_Dim, int],
        expected_ndim: int,
    ) -> None:
        expand_dims = set(broadcast_dims.keys()) - set(target.dims)
        # loop over expand_dims and call .expand_dims(dim=dim) in a loop
        for dim in expand_dims:
>           target = target.expand_dims(dim=dim)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_namedarray.py#x1B[0m:567: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1593: in expand_dims
    from xarray.namedarray._array_api import expand_dims
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
>           warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
#x1B[1m#x1B[31mE           FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:300: FutureWarning

Check warning on line 0 in xarray.tests.test_namedarray.TestNamedArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

2 out of 7 runs failed: test_broadcast_to[broadcast_dims2-3] (xarray.tests.test_namedarray.TestNamedArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
Raw output
FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
self = <xarray.tests.test_namedarray.TestNamedArray object at 0x7f1d54fc72e0>
target = <Namedarray, shape=(2, 5), dims=('x', 'y'), dtype=float64, data=[[0.  0.5 1.  1.5 2. ]
 [2.5 3.  3.5 4.  4.5]]>
broadcast_dims = {'w': 1, 'x': 2, 'y': 5}, expected_ndim = 3

    @pytest.mark.parametrize(
        "broadcast_dims,expected_ndim",
        [
            ({"x": 2, "y": 5}, 2),
            ({"x": 2, "y": 5, "z": 2}, 3),
            ({"w": 1, "x": 2, "y": 5}, 3),
        ],
    )
    def test_broadcast_to(
        self,
        target: NamedArray[Any, np.dtype[np.float32]],
        broadcast_dims: Mapping[_Dim, int],
        expected_ndim: int,
    ) -> None:
        expand_dims = set(broadcast_dims.keys()) - set(target.dims)
        # loop over expand_dims and call .expand_dims(dim=dim) in a loop
        for dim in expand_dims:
>           target = target.expand_dims(dim=dim)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_namedarray.py#x1B[0m:567: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1593: in expand_dims
    from xarray.namedarray._array_api import expand_dims
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
>           warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
#x1B[1m#x1B[31mE           FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:300: FutureWarning

Check warning on line 0 in xarray.tests.test_rolling.TestDataArrayRolling

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 7 runs failed: test_rolling_wrapped_bottleneck[1-None-numpy-None-None-std] (xarray.tests.test_rolling.TestDataArrayRolling)

artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
Raw output
AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool_'?
self = <xarray.tests.test_rolling.TestDataArrayRolling object at 0x7fca30d642b0>
da = <xarray.DataArray (a: 3, time: 21, x: 4)> Size: 2kB
array([[[0.5488135 , 0.71518937, 0.60276338, 0.54488318],
        ...ates:
  * time     (time) datetime64[ns] 168B 2000-01-01 2000-01-02 ... 2000-01-21
Dimensions without coordinates: a, x
name = 'std', center = None, min_periods = None, compute_backend = None

    @pytest.mark.parametrize(
        "name", ("sum", "mean", "std", "min", "max", "median", "argmin", "argmax")
    )
    @pytest.mark.parametrize("center", (True, False, None))
    @pytest.mark.parametrize("min_periods", (1, None))
    @pytest.mark.parametrize("backend", ["numpy"], indirect=True)
    def test_rolling_wrapped_bottleneck(
        self, da, name, center, min_periods, compute_backend
    ) -> None:
        bn = pytest.importorskip("bottleneck", minversion="1.1")
        # Test all bottleneck functions
        rolling_obj = da.rolling(time=7, min_periods=min_periods)
    
        func_name = f"move_{name}"
>       actual = getattr(rolling_obj, name)()

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_rolling.py#x1B[0m:124: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/rolling.py#x1B[0m:177: in method
    return self._array_reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/rolling.py#x1B[0m:693: in _array_reduce
    return self.reduce(array_agg_func, keep_attrs=keep_attrs, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/rolling.py#x1B[0m:499: in reduce
    windows = self._construct(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/rolling.py#x1B[0m:414: in _construct
    window = obj.variable.rolling_window(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:2072: in rolling_window
    var = duck_array_ops.astype(self, dtype, copy=False)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:210: in astype
    xp = get_array_namespace(data)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:65: in get_array_namespace
    namespaces = {_get_array_namespace(t) for t in values}
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:65: in <setcomp>
    namespaces = {_get_array_namespace(t) for t in values}
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:61: in _get_array_namespace
    return x.__array_namespace__()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:462: in __array_namespace__
    import xarray.namedarray._array_api as array_api
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
            warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
    
        if attr in __former_attrs__:
>           raise AttributeError(__former_attrs__[attr])
#x1B[1m#x1B[31mE           AttributeError: module 'numpy' has no attribute 'bool'.#x1B[0m
#x1B[1m#x1B[31mE           `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.#x1B[0m
#x1B[1m#x1B[31mE           The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:#x1B[0m
#x1B[1m#x1B[31mE               https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool_'?#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:305: AttributeError

Check warning on line 0 in xarray.tests.test_rolling.TestDataArrayRolling

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 7 runs failed: test_rolling_wrapped_bottleneck[1-None-numpy-None-None-median] (xarray.tests.test_rolling.TestDataArrayRolling)

artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
Raw output
AttributeError: module 'numpy' has no attribute 'bool'.
`np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool_'?
self = <xarray.tests.test_rolling.TestDataArrayRolling object at 0x7fca30d644f0>
da = <xarray.DataArray (a: 3, time: 21, x: 4)> Size: 2kB
array([[[0.5488135 , 0.71518937, 0.60276338, 0.54488318],
        ...ates:
  * time     (time) datetime64[ns] 168B 2000-01-01 2000-01-02 ... 2000-01-21
Dimensions without coordinates: a, x
name = 'median', center = None, min_periods = None, compute_backend = None

    @pytest.mark.parametrize(
        "name", ("sum", "mean", "std", "min", "max", "median", "argmin", "argmax")
    )
    @pytest.mark.parametrize("center", (True, False, None))
    @pytest.mark.parametrize("min_periods", (1, None))
    @pytest.mark.parametrize("backend", ["numpy"], indirect=True)
    def test_rolling_wrapped_bottleneck(
        self, da, name, center, min_periods, compute_backend
    ) -> None:
        bn = pytest.importorskip("bottleneck", minversion="1.1")
        # Test all bottleneck functions
        rolling_obj = da.rolling(time=7, min_periods=min_periods)
    
        func_name = f"move_{name}"
>       actual = getattr(rolling_obj, name)()

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_rolling.py#x1B[0m:124: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/rolling.py#x1B[0m:177: in method
    return self._array_reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/rolling.py#x1B[0m:693: in _array_reduce
    return self.reduce(array_agg_func, keep_attrs=keep_attrs, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/rolling.py#x1B[0m:499: in reduce
    windows = self._construct(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/rolling.py#x1B[0m:414: in _construct
    window = obj.variable.rolling_window(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:2072: in rolling_window
    var = duck_array_ops.astype(self, dtype, copy=False)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:210: in astype
    xp = get_array_namespace(data)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:65: in get_array_namespace
    namespaces = {_get_array_namespace(t) for t in values}
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:65: in <setcomp>
    namespaces = {_get_array_namespace(t) for t in values}
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:61: in _get_array_namespace
    return x.__array_namespace__()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:462: in __array_namespace__
    import xarray.namedarray._array_api as array_api
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
            warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
    
        if attr in __former_attrs__:
>           raise AttributeError(__former_attrs__[attr])
#x1B[1m#x1B[31mE           AttributeError: module 'numpy' has no attribute 'bool'.#x1B[0m
#x1B[1m#x1B[31mE           `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.#x1B[0m
#x1B[1m#x1B[31mE           The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:#x1B[0m
#x1B[1m#x1B[31mE               https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'bool_'?#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:305: AttributeError

Check warning on line 0 in xarray.tests.test_rolling.TestDataArrayRolling

See this annotation in the file changed.

@github-actions github-actions / Test Results

5 out of 7 runs failed: test_rolling_pandas_compat[numbagg-1-None-True] (xarray.tests.test_rolling.TestDataArrayRolling)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
Raw output
FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
self = <xarray.tests.test_rolling.TestDataArrayRolling object at 0x7f20925e45e0>
center = True, window = 1, min_periods = None, compute_backend = 'numbagg'

    @pytest.mark.parametrize("center", (True, False))
    @pytest.mark.parametrize("min_periods", (None, 1, 2, 3))
    @pytest.mark.parametrize("window", (1, 2, 3, 4))
    def test_rolling_pandas_compat(
        self, center, window, min_periods, compute_backend
    ) -> None:
        s = pd.Series(np.arange(10))
        da = DataArray.from_series(s)
    
        if min_periods is not None and window < min_periods:
            min_periods = window
    
        s_rolling = s.rolling(window, center=center, min_periods=min_periods).mean()
        da_rolling = da.rolling(
            index=window, center=center, min_periods=min_periods
        ).mean()
        da_rolling_np = da.rolling(
            index=window, center=center, min_periods=min_periods
>       ).reduce(np.nanmean)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_rolling.py#x1B[0m:207: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/rolling.py#x1B[0m:499: in reduce
    windows = self._construct(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/rolling.py#x1B[0m:414: in _construct
    window = obj.variable.rolling_window(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:2072: in rolling_window
    var = duck_array_ops.astype(self, dtype, copy=False)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:210: in astype
    xp = get_array_namespace(data)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:65: in get_array_namespace
    namespaces = {_get_array_namespace(t) for t in values}
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:65: in <setcomp>
    namespaces = {_get_array_namespace(t) for t in values}
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:61: in _get_array_namespace
    return x.__array_namespace__()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:462: in __array_namespace__
    import xarray.namedarray._array_api as array_api
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
>           warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
#x1B[1m#x1B[31mE           FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:300: FutureWarning

Check warning on line 0 in xarray.tests.test_rolling.TestDataArrayRolling

See this annotation in the file changed.

@github-actions github-actions / Test Results

5 out of 7 runs failed: test_rolling_pandas_compat[numbagg-1-None-False] (xarray.tests.test_rolling.TestDataArrayRolling)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
Raw output
FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
self = <xarray.tests.test_rolling.TestDataArrayRolling object at 0x7f20925e58a0>
center = False, window = 1, min_periods = None, compute_backend = 'numbagg'

    @pytest.mark.parametrize("center", (True, False))
    @pytest.mark.parametrize("min_periods", (None, 1, 2, 3))
    @pytest.mark.parametrize("window", (1, 2, 3, 4))
    def test_rolling_pandas_compat(
        self, center, window, min_periods, compute_backend
    ) -> None:
        s = pd.Series(np.arange(10))
        da = DataArray.from_series(s)
    
        if min_periods is not None and window < min_periods:
            min_periods = window
    
        s_rolling = s.rolling(window, center=center, min_periods=min_periods).mean()
        da_rolling = da.rolling(
            index=window, center=center, min_periods=min_periods
        ).mean()
        da_rolling_np = da.rolling(
            index=window, center=center, min_periods=min_periods
>       ).reduce(np.nanmean)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_rolling.py#x1B[0m:207: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/rolling.py#x1B[0m:499: in reduce
    windows = self._construct(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/rolling.py#x1B[0m:414: in _construct
    window = obj.variable.rolling_window(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:2072: in rolling_window
    var = duck_array_ops.astype(self, dtype, copy=False)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:210: in astype
    xp = get_array_namespace(data)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:65: in get_array_namespace
    namespaces = {_get_array_namespace(t) for t in values}
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:65: in <setcomp>
    namespaces = {_get_array_namespace(t) for t in values}
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:61: in _get_array_namespace
    return x.__array_namespace__()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:462: in __array_namespace__
    import xarray.namedarray._array_api as array_api
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
>           warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
#x1B[1m#x1B[31mE           FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:300: FutureWarning

Check warning on line 0 in xarray.tests.test_rolling.TestDataArrayRolling

See this annotation in the file changed.

@github-actions github-actions / Test Results

5 out of 7 runs failed: test_rolling_pandas_compat[numbagg-1-1-True] (xarray.tests.test_rolling.TestDataArrayRolling)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
Raw output
FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
self = <xarray.tests.test_rolling.TestDataArrayRolling object at 0x7f20925e7190>
center = True, window = 1, min_periods = 1, compute_backend = 'numbagg'

    @pytest.mark.parametrize("center", (True, False))
    @pytest.mark.parametrize("min_periods", (None, 1, 2, 3))
    @pytest.mark.parametrize("window", (1, 2, 3, 4))
    def test_rolling_pandas_compat(
        self, center, window, min_periods, compute_backend
    ) -> None:
        s = pd.Series(np.arange(10))
        da = DataArray.from_series(s)
    
        if min_periods is not None and window < min_periods:
            min_periods = window
    
        s_rolling = s.rolling(window, center=center, min_periods=min_periods).mean()
        da_rolling = da.rolling(
            index=window, center=center, min_periods=min_periods
        ).mean()
        da_rolling_np = da.rolling(
            index=window, center=center, min_periods=min_periods
>       ).reduce(np.nanmean)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_rolling.py#x1B[0m:207: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/rolling.py#x1B[0m:499: in reduce
    windows = self._construct(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/rolling.py#x1B[0m:414: in _construct
    window = obj.variable.rolling_window(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:2072: in rolling_window
    var = duck_array_ops.astype(self, dtype, copy=False)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:210: in astype
    xp = get_array_namespace(data)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:65: in get_array_namespace
    namespaces = {_get_array_namespace(t) for t in values}
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:65: in <setcomp>
    namespaces = {_get_array_namespace(t) for t in values}
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:61: in _get_array_namespace
    return x.__array_namespace__()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:462: in __array_namespace__
    import xarray.namedarray._array_api as array_api
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
>           warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
#x1B[1m#x1B[31mE           FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:300: FutureWarning

Check warning on line 0 in xarray.tests.test_rolling.TestDataArrayRolling

See this annotation in the file changed.

@github-actions github-actions / Test Results

5 out of 7 runs failed: test_rolling_pandas_compat[numbagg-1-1-False] (xarray.tests.test_rolling.TestDataArrayRolling)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
Raw output
FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.
self = <xarray.tests.test_rolling.TestDataArrayRolling object at 0x7f20925e7100>
center = False, window = 1, min_periods = 1, compute_backend = 'numbagg'

    @pytest.mark.parametrize("center", (True, False))
    @pytest.mark.parametrize("min_periods", (None, 1, 2, 3))
    @pytest.mark.parametrize("window", (1, 2, 3, 4))
    def test_rolling_pandas_compat(
        self, center, window, min_periods, compute_backend
    ) -> None:
        s = pd.Series(np.arange(10))
        da = DataArray.from_series(s)
    
        if min_periods is not None and window < min_periods:
            min_periods = window
    
        s_rolling = s.rolling(window, center=center, min_periods=min_periods).mean()
        da_rolling = da.rolling(
            index=window, center=center, min_periods=min_periods
        ).mean()
        da_rolling_np = da.rolling(
            index=window, center=center, min_periods=min_periods
>       ).reduce(np.nanmean)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_rolling.py#x1B[0m:207: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/rolling.py#x1B[0m:499: in reduce
    windows = self._construct(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/rolling.py#x1B[0m:414: in _construct
    window = obj.variable.rolling_window(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:2072: in rolling_window
    var = duck_array_ops.astype(self, dtype, copy=False)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:210: in astype
    xp = get_array_namespace(data)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:65: in get_array_namespace
    namespaces = {_get_array_namespace(t) for t in values}
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:65: in <setcomp>
    namespaces = {_get_array_namespace(t) for t in values}
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/duck_array_ops.py#x1B[0m:61: in _get_array_namespace
    return x.__array_namespace__()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:462: in __array_namespace__
    import xarray.namedarray._array_api as array_api
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:71: in <module>
    from xarray.namedarray._array_api._dtypes import (
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_dtypes.py#x1B[0m:18: in <module>
    bool = _xp.bool
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

attr = 'bool'

    def __getattr__(attr):
        # Warn for expired attributes, and return a dummy function
        # that always raises an exception.
        import warnings
        try:
            msg = __expired_functions__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
    
            def _expired(*args, **kwds):
                raise RuntimeError(msg)
    
            return _expired
    
        # Emit warnings for deprecated attributes
        try:
            val, msg = __deprecated_attrs__[attr]
        except KeyError:
            pass
        else:
            warnings.warn(msg, DeprecationWarning, stacklevel=2)
            return val
    
        if attr in __future_scalars__:
            # And future warnings for those that will change, but also give
            # the AttributeError
>           warnings.warn(
                f"In the future `np.{attr}` will be defined as the "
                "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
#x1B[1m#x1B[31mE           FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar.#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/numpy/__init__.py#x1B[0m:300: FutureWarning