Skip to content

Add support for Array API in NamedArray #114

Add support for Array API in NamedArray

Add support for Array API in NamedArray #114

GitHub Actions / Test Results failed Aug 25, 2024 in 0s

143 errors, 2 437 fail, 1 785 skipped, 15 581 pass in 16m 41s

     4 files  +     3       4 suites  +3   16m 41s ⏱️ + 15m 36s
19 946 tests +19 934  15 581 ✅ +15 573   1 785 💤 + 1 783  2 437 ❌ +2 437  143 🔥 +141 
50 563 runs  +50 551  33 839 ✅ +33 831  13 662 💤 +13 660  2 759 ❌ +2 759  303 🔥 +301 

Results for commit 09e1478. ± Comparison against earlier commit 4e7dffb.

Annotations

Check failure on line 0 in /

See this annotation in the file changed.

@github-actions github-actions / Test Results

2 out of 4 runs with error: xarray.tests.test_dask

artifacts/Test results for Linux-3.12 flaky/pytest.xml [took 0s]
artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
Raw output
collection failure
collection failure
collection failure
collection failure
#x1B[1m#x1B[31mxarray/tests/test_dask.py#x1B[0m:1127: in <module>
    @pytest.mark.parametrize("obj", [make_ds(), make_da()])
#x1B[1m#x1B[31mxarray/tests/test_dask.py#x1B[0m:1067: in make_ds
    map_ds["a"] = make_da()
#x1B[1m#x1B[31mxarray/tests/test_dask.py#x1B[0m:1060: in make_da
    da.coords["cxy"] = (da.x * da.y).chunk({"x": 4, "y": 5})
#x1B[1m#x1B[31mxarray/core/_typed_ops.py#x1B[0m:253: in __mul__
    return self._binary_op(other, operator.mul)
#x1B[1m#x1B[31mxarray/core/dataarray.py#x1B[0m:4749: in _binary_op
    f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31mxarray/namedarray/core.py#x1B[0m:548: in __mul__
    return multiply(self, asarray(other))
#x1B[1m#x1B[31mxarray/namedarray/_array_api/_elementwise_functions.py#x1B[0m:355: in multiply
    out = x1._new(data=xp.multiply(x1._data, x2._data))
#x1B[1m#x1B[31mE   ValueError: operands could not be broadcast together with shapes (10,) (20,)#x1B[0m
#x1B[1m#x1B[31mxarray/tests/test_dask.py#x1B[0m:1127: in <module>
    @pytest.mark.parametrize("obj", [make_ds(), make_da()])
#x1B[1m#x1B[31mxarray/tests/test_dask.py#x1B[0m:1067: in make_ds
    map_ds["a"] = make_da()
#x1B[1m#x1B[31mxarray/tests/test_dask.py#x1B[0m:1060: in make_da
    da.coords["cxy"] = (da.x * da.y).chunk({"x": 4, "y": 5})
#x1B[1m#x1B[31mxarray/core/_typed_ops.py#x1B[0m:253: in __mul__
    return self._binary_op(other, operator.mul)
#x1B[1m#x1B[31mxarray/core/dataarray.py#x1B[0m:4749: in _binary_op
    f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31mxarray/namedarray/core.py#x1B[0m:548: in __mul__
    return multiply(self, asarray(other))
#x1B[1m#x1B[31mxarray/namedarray/_array_api/_elementwise_functions.py#x1B[0m:355: in multiply
    out = x1._new(data=xp.multiply(x1._data, x2._data))
#x1B[1m#x1B[31mE   ValueError: operands could not be broadcast together with shapes (10,) (20,)#x1B[0m
#x1B[1m#x1B[31mxarray/tests/test_dask.py#x1B[0m:1127: in <module>
    @pytest.mark.parametrize("obj", [make_ds(), make_da()])
#x1B[1m#x1B[31mxarray/tests/test_dask.py#x1B[0m:1067: in make_ds
    map_ds["a"] = make_da()
#x1B[1m#x1B[31mxarray/tests/test_dask.py#x1B[0m:1060: in make_da
    da.coords["cxy"] = (da.x * da.y).chunk({"x": 4, "y": 5})
#x1B[1m#x1B[31mxarray/core/_typed_ops.py#x1B[0m:253: in __mul__
    return self._binary_op(other, operator.mul)
#x1B[1m#x1B[31mxarray/core/dataarray.py#x1B[0m:4749: in _binary_op
    f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31mxarray/namedarray/core.py#x1B[0m:548: in __mul__
    return multiply(self, asarray(other))
#x1B[1m#x1B[31mxarray/namedarray/_array_api/_elementwise_functions.py#x1B[0m:355: in multiply
    out = x1._new(data=xp.multiply(x1._data, x2._data))
#x1B[1m#x1B[31mE   ValueError: operands could not be broadcast together with shapes (10,) (20,)#x1B[0m
#x1B[1m#x1B[31mxarray/tests/test_dask.py#x1B[0m:1127: in <module>
    @pytest.mark.parametrize("obj", [make_ds(), make_da()])
#x1B[1m#x1B[31mxarray/tests/test_dask.py#x1B[0m:1067: in make_ds
    map_ds["a"] = make_da()
#x1B[1m#x1B[31mxarray/tests/test_dask.py#x1B[0m:1060: in make_da
    da.coords["cxy"] = (da.x * da.y).chunk({"x": 4, "y": 5})
#x1B[1m#x1B[31mxarray/core/_typed_ops.py#x1B[0m:253: in __mul__
    return self._binary_op(other, operator.mul)
#x1B[1m#x1B[31mxarray/core/dataarray.py#x1B[0m:4749: in _binary_op
    f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31mxarray/namedarray/core.py#x1B[0m:548: in __mul__
    return multiply(self, asarray(other))
#x1B[1m#x1B[31mxarray/namedarray/_array_api/_elementwise_functions.py#x1B[0m:355: in multiply
    out = x1._new(data=xp.multiply(x1._data, x2._data))
#x1B[1m#x1B[31mE   ValueError: operands could not be broadcast together with shapes (10,) (20,)#x1B[0m

Check warning on line 0 in xarray.tests.test_accessor_dt.TestDatetimeAccessor

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 3 runs failed: test_total_seconds (xarray.tests.test_accessor_dt.TestDatetimeAccessor)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, 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.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
self = <xarray.tests.test_accessor_dt.TestDatetimeAccessor object at 0x7f2f38f4d210>

    def test_total_seconds(self) -> None:
        # Subtract a value in the middle of the range to ensure that some values
        # are negative
>       delta = self.data.time - np.datetime64("2000-01-03")

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_accessor_dt.py#x1B[0m:107: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:250: in __sub__
    return self._binary_op(other, operator.sub)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
    f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:593: in __sub__
    from xarray.namedarray._array_api import asarray, subtract
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:69: 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.
        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)
#x1B[1m#x1B[31mE           DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, 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           Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations#x1B[0m

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

Check warning on line 0 in xarray.tests.test_accessor_dt.TestDatetimeAccessor

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 3 runs failed: test_strftime (xarray.tests.test_accessor_dt.TestDatetimeAccessor)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, 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.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
self = <xarray.tests.test_accessor_dt.TestDatetimeAccessor object at 0x7f2f38e69c30>

    def test_strftime(self) -> None:
>       assert (
            "2000-01-01 01:00:00" == self.data.time.dt.strftime("%Y-%m-%d %H:%M:%S")[1]
        )

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_accessor_dt.py#x1B[0m:140: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:295: in __eq__
    return self._binary_op(other, nputils.array_eq)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
    f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/nputils.py#x1B[0m:113: in array_eq
    return _ensure_bool_is_ndarray(self == other, self, other)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:467: in __eq__
    from xarray.namedarray._array_api import asarray, equal
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:69: 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.
        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)
#x1B[1m#x1B[31mE           DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, 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           Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations#x1B[0m

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

Check warning on line 0 in xarray.tests.test_array_api

See this annotation in the file changed.

@github-actions github-actions / Test Results

All 2 runs failed: test_arithmetic (xarray.tests.test_array_api)

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
TypeError: Only numeric dtypes are allowed in add
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_arithmetic(arrays: tuple[xr.DataArray, xr.DataArray]) -> None:
        np_arr, xp_arr = arrays
        expected = np_arr + 7
>       actual = xp_arr + 7

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_array_api.py#x1B[0m:33: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:247: in __add__
    return self._binary_op(other, operator.add)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
    f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:426: in __add__
    return add(self, asarray(other))
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_elementwise_functions.py#x1B[0m:38: in add
    out = x1._new(data=xp.add(x1._data, x2._data))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

x1 = Array([[ 1.,  2.,  3.],
       [ 4.,  5., nan]], dtype=array_api_strict.float64)
x2 = array(7)

    def add(x1: Array, x2: Array, /) -> Array:
        """
        Array API compatible wrapper for :py:func:`np.add <numpy.add>`.
    
        See its docstring for more information.
        """
        if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes:
>           raise TypeError("Only numeric dtypes are allowed in add")
#x1B[1m#x1B[31mE           TypeError: Only numeric dtypes are allowed in add#x1B[0m

#x1B[1m#x1B[31m/Users/runner/micromamba/envs/xarray-tests/lib/python3.10/site-packages/array_api_strict/_elementwise_functions.py#x1B[0m:65: TypeError

Check warning on line 0 in xarray.tests.test_array_api

See this annotation in the file changed.

@github-actions github-actions / Test Results

All 2 runs failed: test_broadcast_during_arithmetic (xarray.tests.test_array_api)

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: operands could not be broadcast together with shapes (2,3) (2,)
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_broadcast_during_arithmetic(arrays: tuple[xr.DataArray, xr.DataArray]) -> None:
        np_arr, xp_arr = arrays
        np_arr2 = xr.DataArray(np.array([1.0, 2.0]), dims="x")
        xp_arr2 = xr.DataArray(xp.asarray([1.0, 2.0]), dims="x")
    
>       expected = np_arr * np_arr2

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_array_api.py#x1B[0m:81: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:253: in __mul__
    return self._binary_op(other, operator.mul)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
    f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:548: in __mul__
    return multiply(self, asarray(other))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

x1 = <xarray.Variable (x: 2, y: 3)> Size: 48B
array([[ 1.,  2.,  3.],
       [ 4.,  5., nan]])
x2 = <xarray.Variable (x: 2)> Size: 16B
array([1., 2.])

    def multiply(x1, x2, /):
        xp = _get_data_namespace(x1)
        # TODO: Handle attrs? will get x1 now
>       out = x1._new(data=xp.multiply(x1._data, x2._data))
#x1B[1m#x1B[31mE       ValueError: operands could not be broadcast together with shapes (2,3) (2,)#x1B[0m

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_elementwise_functions.py#x1B[0m:355: 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 3 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]
Raw output
TypeError: asarray() got an unexpected keyword argument 'device'
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")
                return super().dims
    
            def __array__(self, dtype=None, copy=None):
                warnings.warn("warning in test")
                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/testing/assertions.py#x1B[0m:295: in _format_message
    abs_diff = max(abs(diff))
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:518: in <genexpr>
    return (asarray(i) for i in self._data)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

obj = 1

    def asarray(
        obj: duckarray[_ShapeType, _DType] | _ArrayLike,
        /,
        *,
        dtype: _DType | None = None,
        device: _Device | None = None,
        copy: bool | None = None,
        dims: _DimsLike = _default,
    ) -> NamedArray[_ShapeType, _DType] | NamedArray[Any, Any]:
        """
        Create a Named array from an array-like object.
    
        Parameters
        ----------
        dims : str or iterable of str
            Name(s) of the dimension(s).
        data : T_DuckArray or ArrayLike
            The actual data that populates the array. Should match the
            shape specified by `dims`.
        attrs : dict, optional
            A dictionary containing any additional information or
            attributes you want to store with the array.
            Default is None, meaning no attributes will be stored.
        """
        data = obj
        if isinstance(data, NamedArray):
            if copy:
                return data.copy()
            else:
                return data
    
        # TODO: dask.array.ma.MaskedArray also exists, better way?
        if isinstance(data, np.ma.MaskedArray):
            mask = np.ma.getmaskarray(data)  # type: ignore[no-untyped-call]
            if mask.any():
                # TODO: requires refactoring/vendoring xarray.core.dtypes and
                # xarray.core.duck_array_ops
                raise NotImplementedError("MaskedArray is not supported yet")
    
            _dims = _infer_dims(data.shape, dims)
            return NamedArray(_dims, data)
    
        if isinstance(data, _arrayfunction_or_api):
            _dims = _infer_dims(data.shape, dims)
            return NamedArray(_dims, data)
    
        if isinstance(data, tuple):
            _data = to_0d_object_array(data)
            _dims = _infer_dims(_data.shape, dims)
            return NamedArray(_dims, _data)
    
        # validate whether the data is valid data types.
>       _data = np.asarray(data, dtype=dtype, device=device, copy=copy)
#x1B[1m#x1B[31mE       TypeError: asarray() got an unexpected keyword argument 'device'#x1B[0m

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_creation_functions.py#x1B[0m:144: TypeError

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 3 runs failed: test_ensure_warnings_not_elevated[assert_duckarray_allclose] (xarray.tests.test_assertions)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
TypeError: asarray() got an unexpected keyword argument 'device'
func = 'assert_duckarray_allclose'

    @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")
                return super().dims
    
            def __array__(self, dtype=None, copy=None):
                warnings.warn("warning in test")
                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/testing/assertions.py#x1B[0m:295: in _format_message
    abs_diff = max(abs(diff))
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:518: in <genexpr>
    return (asarray(i) for i in self._data)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

obj = 1

    def asarray(
        obj: duckarray[_ShapeType, _DType] | _ArrayLike,
        /,
        *,
        dtype: _DType | None = None,
        device: _Device | None = None,
        copy: bool | None = None,
        dims: _DimsLike = _default,
    ) -> NamedArray[_ShapeType, _DType] | NamedArray[Any, Any]:
        """
        Create a Named array from an array-like object.
    
        Parameters
        ----------
        dims : str or iterable of str
            Name(s) of the dimension(s).
        data : T_DuckArray or ArrayLike
            The actual data that populates the array. Should match the
            shape specified by `dims`.
        attrs : dict, optional
            A dictionary containing any additional information or
            attributes you want to store with the array.
            Default is None, meaning no attributes will be stored.
        """
        data = obj
        if isinstance(data, NamedArray):
            if copy:
                return data.copy()
            else:
                return data
    
        # TODO: dask.array.ma.MaskedArray also exists, better way?
        if isinstance(data, np.ma.MaskedArray):
            mask = np.ma.getmaskarray(data)  # type: ignore[no-untyped-call]
            if mask.any():
                # TODO: requires refactoring/vendoring xarray.core.dtypes and
                # xarray.core.duck_array_ops
                raise NotImplementedError("MaskedArray is not supported yet")
    
            _dims = _infer_dims(data.shape, dims)
            return NamedArray(_dims, data)
    
        if isinstance(data, _arrayfunction_or_api):
            _dims = _infer_dims(data.shape, dims)
            return NamedArray(_dims, data)
    
        if isinstance(data, tuple):
            _data = to_0d_object_array(data)
            _dims = _infer_dims(_data.shape, dims)
            return NamedArray(_dims, _data)
    
        # validate whether the data is valid data types.
>       _data = np.asarray(data, dtype=dtype, device=device, copy=copy)
#x1B[1m#x1B[31mE       TypeError: asarray() got an unexpected keyword argument 'device'#x1B[0m

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_creation_functions.py#x1B[0m:144: TypeError

Check warning on line 0 in xarray.tests.test_backends.TestDask

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 3 runs failed: test_open_and_do_math (xarray.tests.test_backends.TestDask)

artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
Raw output
ValueError: dimensions () must have the same length as the number of data dimensions, ndim=1
self = <xarray.tests.test_backends.TestDask object at 0x147e246d0>

    def test_open_and_do_math(self) -> None:
        original = Dataset({"foo": ("x", np.random.randn(10))})
        with create_tmp_file() as tmp:
            original.to_netcdf(tmp)
            with open_mfdataset(tmp, combine="by_coords") as ds:
>               actual = 1.0 * ds

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:4725: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:99: in __rmul__
    return self._binary_op(other, operator.mul, reflexive=True)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7778: in _binary_op
    ds = self._calculate_binary_op(g, other, join=align_type)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7847: in _calculate_binary_op
    new_vars = {k: f(self.variables[k], other_variable) for k in self.data_vars}
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7847: in <dictcomp>
    new_vars = {k: f(self.variables[k], other_variable) for k in self.data_vars}
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7777: in <lambda>
    g = f if not reflexive else lambda x, y: f(y, x)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:680: in __rmul__
    return multiply(asarray(other), self)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_elementwise_functions.py#x1B[0m:355: in multiply
    out = x1._new(data=xp.multiply(x1._data, x2._data))
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:322: in _new
    return _new(self, dims, data, attrs)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:157: in _new
    return cls_(dims_, data, attrs_)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:267: in __init__
    self._dims = self._parse_dimensions(dims)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <[AttributeError("'NamedArray' object has no attribute '_dims'") raised in repr()] NamedArray object at 0x14ebe21c0>
dims = ()

    def _parse_dimensions(self, dims: _DimsLike) -> _Dims:
        dims = (dims,) if isinstance(dims, str) else tuple(dims)
        if len(dims) != self.ndim:
>           raise ValueError(
                f"dimensions {dims} must have the same length as the "
                f"number of data dimensions, ndim={self.ndim}"
            )
#x1B[1m#x1B[31mE           ValueError: dimensions () must have the same length as the number of data dimensions, ndim=1#x1B[0m

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:879: ValueError

Check warning on line 0 in xarray.tests.test_backends.TestPydapOnline

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 4 runs failed: test_cmp_local_file (xarray.tests.test_backends.TestPydapOnline)

artifacts/Test results for Linux-3.12 flaky/pytest.xml [took 36s]
Raw output
ConnectionResetError: [Errno 104] Connection reset by peer
self = <xarray.tests.test_backends.TestPydapOnline object at 0x7f24c68d1580>

    def test_cmp_local_file(self) -> None:
        with self.create_datasets() as (actual, expected):
            assert_equal(actual, expected)
    
            # global attributes should be global attributes on the dataset
            assert "NC_GLOBAL" not in actual.attrs
            assert "history" in actual.attrs
    
            # we don't check attributes exactly with assertDatasetIdentical()
            # because the test DAP server seems to insert some extra
            # attributes not found in the netCDF file.
            assert actual.attrs.keys() == expected.attrs.keys()
    
        with self.create_datasets() as (actual, expected):
>           assert_equal(actual[{"l": 2}], expected[{"l": 2}])

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:4945: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:1897: in equals
    return self._all_compat(other, "equals")
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:1749: in _all_compat
    return self._coord_names == other._coord_names and utils.dict_equiv(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/utils.py#x1B[0m:325: in dict_equiv
    if k not in second or not compat(first[k], second[k]):
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:1747: in compat
    return getattr(x, compat_str)(y)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1775: in equals
    self._data is other._data or equiv(self.data, other.data)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:450: in data
    return self._data.get_duck_array()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/indexing.py#x1B[0m:837: in get_duck_array
    self._ensure_cached()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/indexing.py#x1B[0m:831: in _ensure_cached
    self.array = as_indexable(self.array.get_duck_array())
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/indexing.py#x1B[0m:788: in get_duck_array
    return self.array.get_duck_array()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/indexing.py#x1B[0m:651: in get_duck_array
    array = self.array[self.key]
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/backends/pydap_.py#x1B[0m:47: in __getitem__
    return indexing.explicit_indexing_adapter(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/indexing.py#x1B[0m:1015: in explicit_indexing_adapter
    result = raw_indexing_method(raw_key.tuple)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/backends/pydap_.py#x1B[0m:55: in _getitem
    result = robust_getitem(array, key, catch=ValueError)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/backends/common.py#x1B[0m:163: in robust_getitem
    return array[key]
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.12/site-packages/pydap/model.py#x1B[0m:339: in __getitem__
    out.data = self._get_data_index(index)
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.12/site-packages/pydap/model.py#x1B[0m:371: in _get_data_index
    return self._data[index]
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.12/site-packages/pydap/handlers/dap.py#x1B[0m:392: in __getitem__
    r = GET(
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.12/site-packages/pydap/net.py#x1B[0m:26: in GET
    response = follow_redirect(
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.12/site-packages/pydap/net.py#x1B[0m:79: in follow_redirect
    return get_response(req, application, verify=verify)
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.12/site-packages/pydap/net.py#x1B[0m:88: in get_response
    resp = req.get_response(application)
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.12/site-packages/webob/request.py#x1B[0m:1313: in send
    status, headers, app_iter = self.call_application(
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.12/site-packages/webob/request.py#x1B[0m:1278: in call_application
    app_iter = application(self.environ, start_response)
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.12/site-packages/webob/client.py#x1B[0m:94: in __call__
    res = conn.getresponse()
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.12/http/client.py#x1B[0m:1428: in getresponse
    response.begin()
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.12/http/client.py#x1B[0m:331: in begin
    version, status, reason = self._read_status()
#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.12/http/client.py#x1B[0m:292: in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <socket.SocketIO object at 0x7f24c23de380>
b = <memory at 0x7f24c130b340>

    def readinto(self, b):
        """Read up to len(b) bytes into the writable buffer *b* and return
        the number of bytes read.  If the socket is non-blocking and no bytes
        are available, None is returned.
    
        If *b* is non-empty, a 0 return value indicates that the connection
        was shutdown at the other end.
        """
        self._checkClosed()
        self._checkReadable()
        if self._timeout_occurred:
            raise OSError("cannot read from timed out object")
        while True:
            try:
>               return self._sock.recv_into(b)
#x1B[1m#x1B[31mE               ConnectionResetError: [Errno 104] Connection reset by peer#x1B[0m

#x1B[1m#x1B[31m/home/runner/micromamba/envs/xarray-tests/lib/python3.12/socket.py#x1B[0m:720: ConnectionResetError

Check warning on line 0 in xarray.tests.test_backends

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 3 runs failed: test_open_fsspec (xarray.tests.test_backends)

artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
Raw output
numpy._core._exceptions._UFuncBinaryResolutionError: ufunc 'add' cannot use operands with types dtype('<M8[ns]') and dtype('O')
@requires_zarr
    @requires_fsspec
    @pytest.mark.filterwarnings("ignore:deallocating CachingFileManager")
    def test_open_fsspec() -> None:
        import fsspec
        import zarr
    
        if not hasattr(zarr.storage, "FSStore") or not hasattr(
            zarr.storage.FSStore, "getitems"
        ):
            pytest.skip("zarr too old")
    
        ds = open_dataset(os.path.join(os.path.dirname(__file__), "data", "example_1.nc"))
    
        m = fsspec.filesystem("memory")
        mm = m.get_mapper("out1.zarr")
        ds.to_zarr(mm)  # old interface
        ds0 = ds.copy()
>       ds0["time"] = ds.time + pd.to_timedelta("1 day")

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:5524: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:247: in __add__
    return self._binary_op(other, operator.add)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
    f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:426: in __add__
    return add(self, asarray(other))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

x1 = <xarray.IndexVariable 'time' (time: 1)> Size: 8B
array(['1996-01-01T12:00:00.000000000'], dtype='datetime64[ns]')
x2 = <xarray.NamedArray ()> Size: 8B
array(Timedelta('1 days 00:00:00'), dtype=object)

    def add(x1, x2, /):
        xp = _get_data_namespace(x1)
        # TODO: Handle attrs? will get x1 now
>       out = x1._new(data=xp.add(x1._data, x2._data))
#x1B[1m#x1B[31mE       numpy._core._exceptions._UFuncBinaryResolutionError: ufunc 'add' cannot use operands with types dtype('<M8[ns]') and dtype('O')#x1B[0m

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_elementwise_functions.py#x1B[0m:38: UFuncTypeError

Check warning on line 0 in xarray.tests.test_backends.TestZarrRegionAuto

See this annotation in the file changed.

@github-actions github-actions / Test Results

2 out of 3 runs failed: test_zarr_region_auto_all (xarray.tests.test_backends.TestZarrRegionAuto)

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: dimensions () must have the same length as the number of data dimensions, ndim=2
self = <xarray.tests.test_backends.TestZarrRegionAuto object at 0x147e84310>
tmp_path = PosixPath('/private/var/folders/4d/0gnh84wj53j7wyk695q0tc_80000gn/T/pytest-of-runner/pytest-0/popen-gw1/test_zarr_region_auto_all0')

    def test_zarr_region_auto_all(self, tmp_path):
        x = np.arange(0, 50, 10)
        y = np.arange(0, 20, 2)
        data = np.ones((5, 10))
        ds = xr.Dataset(
            {
                "test": xr.DataArray(
                    data,
                    dims=("x", "y"),
                    coords={"x": x, "y": y},
                )
            }
        )
        ds.to_zarr(tmp_path / "test.zarr")
    
>       ds_region = 1 + ds.isel(x=slice(2, 4), y=slice(6, 8))

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:5827: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:93: in __radd__
    return self._binary_op(other, operator.add, reflexive=True)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7778: in _binary_op
    ds = self._calculate_binary_op(g, other, join=align_type)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7847: in _calculate_binary_op
    new_vars = {k: f(self.variables[k], other_variable) for k in self.data_vars}
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7847: in <dictcomp>
    new_vars = {k: f(self.variables[k], other_variable) for k in self.data_vars}
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7777: in <lambda>
    g = f if not reflexive else lambda x, y: f(y, x)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:616: in __radd__
    return add(asarray(other), self)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_elementwise_functions.py#x1B[0m:38: in add
    out = x1._new(data=xp.add(x1._data, x2._data))
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:322: in _new
    return _new(self, dims, data, attrs)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:157: in _new
    return cls_(dims_, data, attrs_)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:267: in __init__
    self._dims = self._parse_dimensions(dims)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <[AttributeError("'NamedArray' object has no attribute '_dims'") raised in repr()] NamedArray object at 0x14ef3a740>
dims = ()

    def _parse_dimensions(self, dims: _DimsLike) -> _Dims:
        dims = (dims,) if isinstance(dims, str) else tuple(dims)
        if len(dims) != self.ndim:
>           raise ValueError(
                f"dimensions {dims} must have the same length as the "
                f"number of data dimensions, ndim={self.ndim}"
            )
#x1B[1m#x1B[31mE           ValueError: dimensions () must have the same length as the number of data dimensions, ndim=2#x1B[0m

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:879: ValueError

Check warning on line 0 in xarray.tests.test_backends.TestZarrRegionAuto

See this annotation in the file changed.

@github-actions github-actions / Test Results

2 out of 3 runs failed: test_zarr_region_auto_mixed (xarray.tests.test_backends.TestZarrRegionAuto)

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: dimensions () must have the same length as the number of data dimensions, ndim=2
self = <xarray.tests.test_backends.TestZarrRegionAuto object at 0x147e84550>
tmp_path = PosixPath('/private/var/folders/4d/0gnh84wj53j7wyk695q0tc_80000gn/T/pytest-of-runner/pytest-0/popen-gw1/test_zarr_region_auto_mixed0')

    def test_zarr_region_auto_mixed(self, tmp_path):
        x = np.arange(0, 50, 10)
        y = np.arange(0, 20, 2)
        data = np.ones((5, 10))
        ds = xr.Dataset(
            {
                "test": xr.DataArray(
                    data,
                    dims=("x", "y"),
                    coords={"x": x, "y": y},
                )
            }
        )
        ds.to_zarr(tmp_path / "test.zarr")
    
>       ds_region = 1 + ds.isel(x=slice(2, 4), y=slice(6, 8))

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:5851: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:93: in __radd__
    return self._binary_op(other, operator.add, reflexive=True)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7778: in _binary_op
    ds = self._calculate_binary_op(g, other, join=align_type)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7847: in _calculate_binary_op
    new_vars = {k: f(self.variables[k], other_variable) for k in self.data_vars}
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7847: in <dictcomp>
    new_vars = {k: f(self.variables[k], other_variable) for k in self.data_vars}
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7777: in <lambda>
    g = f if not reflexive else lambda x, y: f(y, x)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:616: in __radd__
    return add(asarray(other), self)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_elementwise_functions.py#x1B[0m:38: in add
    out = x1._new(data=xp.add(x1._data, x2._data))
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:322: in _new
    return _new(self, dims, data, attrs)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:157: in _new
    return cls_(dims_, data, attrs_)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:267: in __init__
    self._dims = self._parse_dimensions(dims)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <[AttributeError("'NamedArray' object has no attribute '_dims'") raised in repr()] NamedArray object at 0x14e4df640>
dims = ()

    def _parse_dimensions(self, dims: _DimsLike) -> _Dims:
        dims = (dims,) if isinstance(dims, str) else tuple(dims)
        if len(dims) != self.ndim:
>           raise ValueError(
                f"dimensions {dims} must have the same length as the "
                f"number of data dimensions, ndim={self.ndim}"
            )
#x1B[1m#x1B[31mE           ValueError: dimensions () must have the same length as the number of data dimensions, ndim=2#x1B[0m

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:879: ValueError

Check warning on line 0 in xarray.tests.test_backends.TestZarrRegionAuto

See this annotation in the file changed.

@github-actions github-actions / Test Results

2 out of 3 runs failed: test_zarr_region_auto_noncontiguous (xarray.tests.test_backends.TestZarrRegionAuto)

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: dimensions () must have the same length as the number of data dimensions, ndim=2
self = <xarray.tests.test_backends.TestZarrRegionAuto object at 0x147e84790>
tmp_path = PosixPath('/private/var/folders/4d/0gnh84wj53j7wyk695q0tc_80000gn/T/pytest-of-runner/pytest-0/popen-gw1/test_zarr_region_auto_nonconti0')

    def test_zarr_region_auto_noncontiguous(self, tmp_path):
        x = np.arange(0, 50, 10)
        y = np.arange(0, 20, 2)
        data = np.ones((5, 10))
        ds = xr.Dataset(
            {
                "test": xr.DataArray(
                    data,
                    dims=("x", "y"),
                    coords={"x": x, "y": y},
                )
            }
        )
        ds.to_zarr(tmp_path / "test.zarr")
    
>       ds_region = 1 + ds.isel(x=[0, 2, 3], y=[5, 6])

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:5877: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:93: in __radd__
    return self._binary_op(other, operator.add, reflexive=True)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7778: in _binary_op
    ds = self._calculate_binary_op(g, other, join=align_type)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7847: in _calculate_binary_op
    new_vars = {k: f(self.variables[k], other_variable) for k in self.data_vars}
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7847: in <dictcomp>
    new_vars = {k: f(self.variables[k], other_variable) for k in self.data_vars}
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7777: in <lambda>
    g = f if not reflexive else lambda x, y: f(y, x)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:616: in __radd__
    return add(asarray(other), self)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_elementwise_functions.py#x1B[0m:38: in add
    out = x1._new(data=xp.add(x1._data, x2._data))
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:322: in _new
    return _new(self, dims, data, attrs)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:157: in _new
    return cls_(dims_, data, attrs_)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:267: in __init__
    self._dims = self._parse_dimensions(dims)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <[AttributeError("'NamedArray' object has no attribute '_dims'") raised in repr()] NamedArray object at 0x14eeb49c0>
dims = ()

    def _parse_dimensions(self, dims: _DimsLike) -> _Dims:
        dims = (dims,) if isinstance(dims, str) else tuple(dims)
        if len(dims) != self.ndim:
>           raise ValueError(
                f"dimensions {dims} must have the same length as the "
                f"number of data dimensions, ndim={self.ndim}"
            )
#x1B[1m#x1B[31mE           ValueError: dimensions () must have the same length as the number of data dimensions, ndim=2#x1B[0m

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:879: ValueError

Check warning on line 0 in xarray.tests.test_backends.TestZarrRegionAuto

See this annotation in the file changed.

@github-actions github-actions / Test Results

2 out of 3 runs failed: test_zarr_region_auto_new_coord_vals (xarray.tests.test_backends.TestZarrRegionAuto)

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: dimensions () must have the same length as the number of data dimensions, ndim=2
self = <xarray.tests.test_backends.TestZarrRegionAuto object at 0x147e849d0>
tmp_path = PosixPath('/private/var/folders/4d/0gnh84wj53j7wyk695q0tc_80000gn/T/pytest-of-runner/pytest-0/popen-gw1/test_zarr_region_auto_new_coor0')

    def test_zarr_region_auto_new_coord_vals(self, tmp_path):
        x = np.arange(0, 50, 10)
        y = np.arange(0, 20, 2)
        data = np.ones((5, 10))
        ds = xr.Dataset(
            {
                "test": xr.DataArray(
                    data,
                    dims=("x", "y"),
                    coords={"x": x, "y": y},
                )
            }
        )
        ds.to_zarr(tmp_path / "test.zarr")
    
        x = np.arange(5, 55, 10)
        y = np.arange(0, 20, 2)
        data = np.ones((5, 10))
        ds = xr.Dataset(
            {
                "test": xr.DataArray(
                    data,
                    dims=("x", "y"),
                    coords={"x": x, "y": y},
                )
            }
        )
    
>       ds_region = 1 + ds.isel(x=slice(2, 4), y=slice(6, 8))

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:5909: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:93: in __radd__
    return self._binary_op(other, operator.add, reflexive=True)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7778: in _binary_op
    ds = self._calculate_binary_op(g, other, join=align_type)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7847: in _calculate_binary_op
    new_vars = {k: f(self.variables[k], other_variable) for k in self.data_vars}
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7847: in <dictcomp>
    new_vars = {k: f(self.variables[k], other_variable) for k in self.data_vars}
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7777: in <lambda>
    g = f if not reflexive else lambda x, y: f(y, x)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:616: in __radd__
    return add(asarray(other), self)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_elementwise_functions.py#x1B[0m:38: in add
    out = x1._new(data=xp.add(x1._data, x2._data))
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:322: in _new
    return _new(self, dims, data, attrs)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:157: in _new
    return cls_(dims_, data, attrs_)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:267: in __init__
    self._dims = self._parse_dimensions(dims)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <[AttributeError("'NamedArray' object has no attribute '_dims'") raised in repr()] NamedArray object at 0x14fc94640>
dims = ()

    def _parse_dimensions(self, dims: _DimsLike) -> _Dims:
        dims = (dims,) if isinstance(dims, str) else tuple(dims)
        if len(dims) != self.ndim:
>           raise ValueError(
                f"dimensions {dims} must have the same length as the "
                f"number of data dimensions, ndim={self.ndim}"
            )
#x1B[1m#x1B[31mE           ValueError: dimensions () must have the same length as the number of data dimensions, ndim=2#x1B[0m

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:879: ValueError

Check warning on line 0 in xarray.tests.test_backends.TestZarrRegionAuto

See this annotation in the file changed.

@github-actions github-actions / Test Results

2 out of 3 runs failed: test_zarr_region_index_write (xarray.tests.test_backends.TestZarrRegionAuto)

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: dimensions () must have the same length as the number of data dimensions, ndim=2
self = <xarray.tests.test_backends.TestZarrRegionAuto object at 0x147e84c10>
tmp_path = PosixPath('/private/var/folders/4d/0gnh84wj53j7wyk695q0tc_80000gn/T/pytest-of-runner/pytest-0/popen-gw1/test_zarr_region_index_write0')

    def test_zarr_region_index_write(self, tmp_path):
        from xarray.backends.zarr import ZarrStore
    
        x = np.arange(0, 50, 10)
        y = np.arange(0, 20, 2)
        data = np.ones((5, 10))
        ds = xr.Dataset(
            {
                "test": xr.DataArray(
                    data,
                    dims=("x", "y"),
                    coords={"x": x, "y": y},
                )
            }
        )
    
        region_slice = dict(x=slice(2, 4), y=slice(6, 8))
>       ds_region = 1 + ds.isel(region_slice)

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:5930: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:93: in __radd__
    return self._binary_op(other, operator.add, reflexive=True)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7778: in _binary_op
    ds = self._calculate_binary_op(g, other, join=align_type)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7847: in _calculate_binary_op
    new_vars = {k: f(self.variables[k], other_variable) for k in self.data_vars}
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7847: in <dictcomp>
    new_vars = {k: f(self.variables[k], other_variable) for k in self.data_vars}
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7777: in <lambda>
    g = f if not reflexive else lambda x, y: f(y, x)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:616: in __radd__
    return add(asarray(other), self)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_elementwise_functions.py#x1B[0m:38: in add
    out = x1._new(data=xp.add(x1._data, x2._data))
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:322: in _new
    return _new(self, dims, data, attrs)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:157: in _new
    return cls_(dims_, data, attrs_)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:267: in __init__
    self._dims = self._parse_dimensions(dims)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <[AttributeError("'NamedArray' object has no attribute '_dims'") raised in repr()] NamedArray object at 0x14fa1fc80>
dims = ()

    def _parse_dimensions(self, dims: _DimsLike) -> _Dims:
        dims = (dims,) if isinstance(dims, str) else tuple(dims)
        if len(dims) != self.ndim:
>           raise ValueError(
                f"dimensions {dims} must have the same length as the "
                f"number of data dimensions, ndim={self.ndim}"
            )
#x1B[1m#x1B[31mE           ValueError: dimensions () must have the same length as the number of data dimensions, ndim=2#x1B[0m

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:879: ValueError

Check warning on line 0 in xarray.tests.test_dataarray.TestDataArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 3 runs failed: test_getitem (xarray.tests.test_dataarray.TestDataArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, 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.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
self = <xarray.tests.test_dataarray.TestDataArray object at 0x7f64c5210f10>

    def test_getitem(self) -> None:
        # strings pull out dataarrays
        assert_identical(self.dv, self.ds["foo"])
        x = self.dv["x"]
        y = self.dv["y"]
        assert_identical(self.ds["x"], x)
        assert_identical(self.ds["y"], y)
    
        arr = ReturnItem()
        for i in [
            arr[:],
            arr[...],
            arr[x.values],
            arr[x.variable],
            arr[x],
            arr[x, y],
            arr[x.values > -1],
>           arr[x.variable > -1],
            arr[x > -1],
            arr[x > -1, y > -1],
        ]:

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_dataarray.py#x1B[0m:610: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:499: in __gt__
    from xarray.namedarray._array_api import asarray, greater
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:69: 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.
        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)
#x1B[1m#x1B[31mE           DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, 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           Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations#x1B[0m

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

Check warning on line 0 in xarray.tests.test_dataarray.TestDataArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

All 3 runs failed: test_setitem_vectorized (xarray.tests.test_dataarray.TestDataArray)

artifacts/Test results for Linux-3.10 bare-minimum/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: operands could not be broadcast together with shapes (2,2,2,5) (2,)
self = <xarray.tests.test_dataarray.TestDataArray object at 0x12b8d2260>

    def test_setitem_vectorized(self) -> None:
        # Regression test for GH:7030
        # Positional indexing
        v = xr.DataArray(np.r_[:120].reshape(2, 3, 4, 5), dims=["a", "b", "c", "d"])
        b = xr.DataArray([[0, 0], [1, 0]], dims=["u", "v"])
        c = xr.DataArray([[0, 1], [2, 3]], dims=["u", "v"])
        w = xr.DataArray([-1, -2], dims=["u"])
        index = dict(b=b, c=c)
        v[index] = w
>       assert (v[index] == w).all()

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_dataarray.py#x1B[0m:860: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:295: in __eq__
    return self._binary_op(other, nputils.array_eq)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
    f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/nputils.py#x1B[0m:113: in array_eq
    return _ensure_bool_is_ndarray(self == other, self, other)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:469: in __eq__
    return equal(self, asarray(other))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

x1 = <xarray.Variable (a: 2, u: 2, v: 2, d: 5)> Size: 320B
array([[[[-1, -1, -1, -1, -1],
         [-1, -1, -1, -1, -1]],

...[-1, -1, -1, -1, -1],
         [-1, -1, -1, -1, -1]],

        [[-2, -2, -2, -2, -2],
         [-2, -2, -2, -2, -2]]]])
x2 = <xarray.Variable (u: 2)> Size: 16B
array([-1, -2])

    def equal(x1, x2, /):
        xp = _get_data_namespace(x1)
        # TODO: Handle attrs? will get x1 now
>       out = x1._new(data=xp.equal(x1._data, x2._data))
#x1B[1m#x1B[31mE       ValueError: operands could not be broadcast together with shapes (2,2,2,5) (2,)#x1B[0m

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_elementwise_functions.py#x1B[0m:178: ValueError

Check warning on line 0 in xarray.tests.test_backends

See this annotation in the file changed.

@github-actions github-actions / Test Results

2 out of 3 runs failed: test_zarr_region (xarray.tests.test_backends)

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: dimensions () must have the same length as the number of data dimensions, ndim=2
tmp_path = PosixPath('/private/var/folders/4d/0gnh84wj53j7wyk695q0tc_80000gn/T/pytest-of-runner/pytest-0/popen-gw1/test_zarr_region0')

    @requires_zarr
    def test_zarr_region(tmp_path):
        x = np.arange(0, 50, 10)
        y = np.arange(0, 20, 2)
        data = np.ones((5, 10))
        ds = xr.Dataset(
            {
                "test": xr.DataArray(
                    data,
                    dims=("x", "y"),
                    coords={"x": x, "y": y},
                )
            }
        )
        ds.to_zarr(tmp_path / "test.zarr")
    
        ds_transposed = ds.transpose("y", "x")
    
>       ds_region = 1 + ds_transposed.isel(x=[0], y=[0])

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:6004: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:93: in __radd__
    return self._binary_op(other, operator.add, reflexive=True)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7778: in _binary_op
    ds = self._calculate_binary_op(g, other, join=align_type)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7847: in _calculate_binary_op
    new_vars = {k: f(self.variables[k], other_variable) for k in self.data_vars}
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7847: in <dictcomp>
    new_vars = {k: f(self.variables[k], other_variable) for k in self.data_vars}
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7777: in <lambda>
    g = f if not reflexive else lambda x, y: f(y, x)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:616: in __radd__
    return add(asarray(other), self)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_elementwise_functions.py#x1B[0m:38: in add
    out = x1._new(data=xp.add(x1._data, x2._data))
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:322: in _new
    return _new(self, dims, data, attrs)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:157: in _new
    return cls_(dims_, data, attrs_)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:267: in __init__
    self._dims = self._parse_dimensions(dims)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <[AttributeError("'NamedArray' object has no attribute '_dims'") raised in repr()] NamedArray object at 0x14db37500>
dims = ()

    def _parse_dimensions(self, dims: _DimsLike) -> _Dims:
        dims = (dims,) if isinstance(dims, str) else tuple(dims)
        if len(dims) != self.ndim:
>           raise ValueError(
                f"dimensions {dims} must have the same length as the "
                f"number of data dimensions, ndim={self.ndim}"
            )
#x1B[1m#x1B[31mE           ValueError: dimensions () must have the same length as the number of data dimensions, ndim=2#x1B[0m

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:879: ValueError

Check warning on line 0 in xarray.tests.test_dataarray.TestDataArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 3 runs failed: test_sel (xarray.tests.test_dataarray.TestDataArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, 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.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
self = <xarray.tests.test_dataarray.TestDataArray object at 0x7f64c52bca90>

    def test_sel(self) -> None:
        self.ds["x"] = ("x", np.array(list("abcdefghij")))
        da = self.ds["foo"]
        assert_identical(da, da.sel(x=slice(None)))
        assert_identical(da[1], da.sel(x="b"))
        assert_identical(da[:3], da.sel(x=slice("c")))
        assert_identical(da[:3], da.sel(x=["a", "b", "c"]))
>       assert_identical(da[:, :4], da.sel(y=(self.ds["y"] < 4)))

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_dataarray.py#x1B[0m:1042: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:283: in __lt__
    return self._binary_op(other, operator.lt)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
    f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:531: in __lt__
    from xarray.namedarray._array_api import asarray, less
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:69: 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.
        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)
#x1B[1m#x1B[31mE           DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, 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           Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations#x1B[0m

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

Check warning on line 0 in xarray.tests.test_dataarray.TestDataArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 3 runs failed: test_sel_no_index (xarray.tests.test_dataarray.TestDataArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, 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.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
self = <xarray.tests.test_dataarray.TestDataArray object at 0x7f64c52be920>

    def test_sel_no_index(self) -> None:
        array = DataArray(np.arange(10), dims="x")
        assert_identical(array[0], array.sel(x=0))
        assert_identical(array[:5], array.sel(x=slice(5)))
        assert_identical(array[[0, -1]], array.sel(x=[0, -1]))
>       assert_identical(array[array < 5], array.sel(x=(array < 5)))

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_dataarray.py#x1B[0m:1157: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:283: in __lt__
    return self._binary_op(other, operator.lt)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
    f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:531: in __lt__
    from xarray.namedarray._array_api import asarray, less
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:69: 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.
        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)
#x1B[1m#x1B[31mE           DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, 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           Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations#x1B[0m

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

Check warning on line 0 in xarray.tests.test_dataarray.TestDataArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 3 runs failed: test_loc (xarray.tests.test_dataarray.TestDataArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, 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.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
self = <xarray.tests.test_dataarray.TestDataArray object at 0x7f64c52bf280>

    def test_loc(self) -> None:
        self.ds["x"] = ("x", np.array(list("abcdefghij")))
        da = self.ds["foo"]
        # typing issue: see https://github.com/python/mypy/issues/2410
        assert_identical(da[:3], da.loc[:"c"])  # type: ignore[misc]
        assert_identical(da[1], da.loc["b"])
        assert_identical(da[1], da.loc[{"x": "b"}])
        assert_identical(da[1], da.loc["b", ...])
        assert_identical(da[:3], da.loc[["a", "b", "c"]])
        assert_identical(da[:3, :4], da.loc[["a", "b", "c"], np.arange(4)])
>       assert_identical(da[:, :4], da.loc[:, self.ds["y"] < 4])

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_dataarray.py#x1B[0m:1256: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:283: in __lt__
    return self._binary_op(other, operator.lt)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
    f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:531: in __lt__
    from xarray.namedarray._array_api import asarray, less
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:69: 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.
        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)
#x1B[1m#x1B[31mE           DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, 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           Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations#x1B[0m

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

Check warning on line 0 in xarray.tests.test_dataarray.TestDataArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 3 runs failed: test_loc_single_boolean (xarray.tests.test_dataarray.TestDataArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, 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.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
self = <xarray.tests.test_dataarray.TestDataArray object at 0x7f64c3bb1cc0>

    def test_loc_single_boolean(self) -> None:
        data = DataArray([0, 1], coords=[[True, False]])
>       assert data.loc[True] == 0

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_dataarray.py#x1B[0m:1336: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:295: in __eq__
    return self._binary_op(other, nputils.array_eq)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
    f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/nputils.py#x1B[0m:113: in array_eq
    return _ensure_bool_is_ndarray(self == other, self, other)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:467: in __eq__
    from xarray.namedarray._array_api import asarray, equal
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:69: 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.
        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)
#x1B[1m#x1B[31mE           DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, 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           Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations#x1B[0m

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

Check warning on line 0 in xarray.tests.test_dataarray.TestDataArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 3 runs failed: test_selection_multiindex_remove_unused (xarray.tests.test_dataarray.TestDataArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, 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.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
self = <xarray.tests.test_dataarray.TestDataArray object at 0x7f64c3bb0550>

    def test_selection_multiindex_remove_unused(self) -> None:
        # GH2619. For MultiIndex, we need to call remove_unused.
        ds = xr.DataArray(
            np.arange(40).reshape(8, 5),
            dims=["x", "y"],
            coords={"x": np.arange(8), "y": np.arange(5)},
        )
        ds = ds.stack(xy=["x", "y"])
>       ds_isel = ds.isel(xy=ds["x"] < 4)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_dataarray.py#x1B[0m:1397: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:283: in __lt__
    return self._binary_op(other, operator.lt)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
    f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:531: in __lt__
    from xarray.namedarray._array_api import asarray, less
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:69: 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.
        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)
#x1B[1m#x1B[31mE           DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, 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           Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations#x1B[0m

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

Check warning on line 0 in xarray.tests.test_dataarray.TestDataArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

All 3 runs failed: test_math (xarray.tests.test_dataarray.TestDataArray)

artifacts/Test results for Linux-3.10 bare-minimum/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: dimensions () must have the same length as the number of data dimensions, ndim=2
self = <xarray.tests.test_dataarray.TestDataArray object at 0x12b921f90>

    def test_math(self) -> None:
        x = self.x
        v = self.v
        a = self.dv
        # variable math was already tested extensively, so let's just make sure
        # that all types are properly converted here
        assert_equal(a, +a)
        assert_equal(a, a + 0)
>       assert_equal(a, 0 + a)

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_dataarray.py#x1B[0m:2298: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:305: in __radd__
    return self._binary_op(other, operator.add, reflexive=True)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4751: in _binary_op
    else f(other_variable_or_arraylike, self.variable)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:616: in __radd__
    return add(asarray(other), self)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_elementwise_functions.py#x1B[0m:38: in add
    out = x1._new(data=xp.add(x1._data, x2._data))
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:322: in _new
    return _new(self, dims, data, attrs)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:157: in _new
    return cls_(dims_, data, attrs_)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:267: in __init__
    self._dims = self._parse_dimensions(dims)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <[AttributeError("'NamedArray' object has no attribute '_dims'") raised in repr()] NamedArray object at 0x12fc95840>
dims = ()

    def _parse_dimensions(self, dims: _DimsLike) -> _Dims:
        dims = (dims,) if isinstance(dims, str) else tuple(dims)
        if len(dims) != self.ndim:
>           raise ValueError(
                f"dimensions {dims} must have the same length as the "
                f"number of data dimensions, ndim={self.ndim}"
            )
#x1B[1m#x1B[31mE           ValueError: dimensions () must have the same length as the number of data dimensions, ndim=2#x1B[0m

#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:879: ValueError

Check warning on line 0 in xarray.tests.test_dataarray.TestDataArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 3 runs failed: test_math_automatic_alignment (xarray.tests.test_dataarray.TestDataArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, 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.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
self = <xarray.tests.test_dataarray.TestDataArray object at 0x7f87da28b220>

    def test_math_automatic_alignment(self) -> None:
        a = DataArray(range(5), [("x", range(5))])
        b = DataArray(range(5), [("x", range(1, 6))])
        expected = DataArray(np.ones(4), [("x", [1, 2, 3, 4])])
>       assert_identical(a - b, expected)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_dataarray.py#x1B[0m:2310: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:250: in __sub__
    return self._binary_op(other, operator.sub)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
    f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:593: in __sub__
    from xarray.namedarray._array_api import asarray, subtract
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:69: 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.
        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)
#x1B[1m#x1B[31mE           DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, 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           Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations#x1B[0m

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