Skip to content

Add support for Array API in NamedArray #125

Add support for Array API in NamedArray

Add support for Array API in NamedArray #125

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

143 errors, 2 434 fail, 1 785 skipped, 15 584 pass in 39m 7s

      7 files  +      7       7 suites  +7   39m 7s ⏱️ + 39m 7s
 19 946 tests + 19 946  15 584 ✅ +15 584   1 785 💤 + 1 785  2 434 ❌ +2 434  143 🔥 +143 
102 181 runs  +102 181  81 572 ✅ +81 572  16 059 💤 +16 059  4 004 ❌ +4 004  546 🔥 +546 

Results for commit 7b8592a. ± Comparison against earlier commit d3efb66.

Annotations

Check failure on line 0 in /

See this annotation in the file changed.

@github-actions github-actions / Test Results

5 out of 7 runs with error: xarray.tests.test_dask

artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12 flaky/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
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 6 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 0x7fce307e1210>

    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: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.
        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 6 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 0x7fce30501c60>

    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: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.
        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 5 runs failed: test_arithmetic (xarray.tests.test_array_api)

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: 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/home/runner/work/xarray/xarray/xarray/tests/test_array_api.py#x1B[0m:33: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/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/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:426: in __add__
    return add(self, asarray(other))
#x1B[1m#x1B[31m/home/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/home/runner/micromamba/envs/xarray-tests/lib/python3.12/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 5 runs failed: test_broadcast_during_arithmetic (xarray.tests.test_array_api)

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
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/home/runner/work/xarray/xarray/xarray/tests/test_array_api.py#x1B[0m:81: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/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/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: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/home/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 6 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 6 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

4 out of 6 runs failed: test_open_and_do_math (xarray.tests.test_backends.TestDask)

artifacts/Test results for Linux-3.10/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
ValueError: dimensions () must have the same length as the number of data dimensions, ndim=1
self = <xarray.tests.test_backends.TestDask object at 0x7f3940f88da0>

    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/home/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:4725: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/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/home/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/home/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/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:680: in __rmul__
    return multiply(asarray(other), self)
#x1B[1m#x1B[31m/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:322: in _new
    return _new(self, dims, data, attrs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:157: in _new
    return cls_(dims_, data, attrs_)
#x1B[1m#x1B[31m/home/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 0x7f3937498d80>
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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:886: ValueError

Check warning on line 0 in xarray.tests.test_backends

See this annotation in the file changed.

@github-actions github-actions / Test Results

4 out of 6 runs failed: test_open_fsspec (xarray.tests.test_backends)

artifacts/Test results for Linux-3.10/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
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/home/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:5524: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/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/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: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/home/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

5 out of 6 runs failed: test_zarr_region_auto_all (xarray.tests.test_backends.TestZarrRegionAuto)

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
ValueError: dimensions () must have the same length as the number of data dimensions, ndim=2
self = <xarray.tests.test_backends.TestZarrRegionAuto object at 0x7f39409a0650>
tmp_path = PosixPath('/tmp/pytest-of-runner/pytest-0/popen-gw2/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/home/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:5827: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/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/home/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/home/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/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:616: in __radd__
    return add(asarray(other), self)
#x1B[1m#x1B[31m/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:322: in _new
    return _new(self, dims, data, attrs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:157: in _new
    return cls_(dims_, data, attrs_)
#x1B[1m#x1B[31m/home/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 0x7f3935bbffc0>
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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:886: 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

5 out of 6 runs failed: test_zarr_region_auto_mixed (xarray.tests.test_backends.TestZarrRegionAuto)

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
ValueError: dimensions () must have the same length as the number of data dimensions, ndim=2
self = <xarray.tests.test_backends.TestZarrRegionAuto object at 0x7f39409a0830>
tmp_path = PosixPath('/tmp/pytest-of-runner/pytest-0/popen-gw2/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/home/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:5851: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/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/home/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/home/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/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:616: in __radd__
    return add(asarray(other), self)
#x1B[1m#x1B[31m/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:322: in _new
    return _new(self, dims, data, attrs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:157: in _new
    return cls_(dims_, data, attrs_)
#x1B[1m#x1B[31m/home/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 0x7f392cb15680>
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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:886: 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

5 out of 6 runs failed: test_zarr_region_auto_noncontiguous (xarray.tests.test_backends.TestZarrRegionAuto)

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
ValueError: dimensions () must have the same length as the number of data dimensions, ndim=2
self = <xarray.tests.test_backends.TestZarrRegionAuto object at 0x7f39409a0a70>
tmp_path = PosixPath('/tmp/pytest-of-runner/pytest-0/popen-gw2/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/home/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:5877: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/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/home/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/home/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/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:616: in __radd__
    return add(asarray(other), self)
#x1B[1m#x1B[31m/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:322: in _new
    return _new(self, dims, data, attrs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:157: in _new
    return cls_(dims_, data, attrs_)
#x1B[1m#x1B[31m/home/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 0x7f3936194040>
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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:886: 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

5 out of 6 runs failed: test_zarr_region_auto_new_coord_vals (xarray.tests.test_backends.TestZarrRegionAuto)

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
ValueError: dimensions () must have the same length as the number of data dimensions, ndim=2
self = <xarray.tests.test_backends.TestZarrRegionAuto object at 0x7f39409a0cb0>
tmp_path = PosixPath('/tmp/pytest-of-runner/pytest-0/popen-gw2/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/home/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:5909: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/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/home/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/home/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/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:616: in __radd__
    return add(asarray(other), self)
#x1B[1m#x1B[31m/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:322: in _new
    return _new(self, dims, data, attrs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:157: in _new
    return cls_(dims_, data, attrs_)
#x1B[1m#x1B[31m/home/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 0x7f392c93eb40>
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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:886: 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

5 out of 6 runs failed: test_zarr_region_index_write (xarray.tests.test_backends.TestZarrRegionAuto)

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
ValueError: dimensions () must have the same length as the number of data dimensions, ndim=2
self = <xarray.tests.test_backends.TestZarrRegionAuto object at 0x7f39409a0f50>
tmp_path = PosixPath('/tmp/pytest-of-runner/pytest-0/popen-gw2/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/home/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:5930: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/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/home/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/home/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/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:616: in __radd__
    return add(asarray(other), self)
#x1B[1m#x1B[31m/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:322: in _new
    return _new(self, dims, data, attrs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:157: in _new
    return cls_(dims_, data, attrs_)
#x1B[1m#x1B[31m/home/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 0x7f3935d10380>
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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:886: ValueError

Check warning on line 0 in xarray.tests.test_backends

See this annotation in the file changed.

@github-actions github-actions / Test Results

5 out of 6 runs failed: test_zarr_region (xarray.tests.test_backends)

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
ValueError: dimensions () must have the same length as the number of data dimensions, ndim=2
tmp_path = PosixPath('/tmp/pytest-of-runner/pytest-0/popen-gw2/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/home/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:6004: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/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/home/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/home/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/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:616: in __radd__
    return add(asarray(other), self)
#x1B[1m#x1B[31m/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:322: in _new
    return _new(self, dims, data, attrs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:157: in _new
    return cls_(dims_, data, attrs_)
#x1B[1m#x1B[31m/home/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 0x7f3936fb3180>
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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:886: 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 6 runs failed: test_getitem (xarray.tests.test_dataarray.TestDataArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
TypeError: asarray() got an unexpected keyword argument 'device'
self = <xarray.tests.test_dataarray.TestDataArray object at 0x7fce2dcccc70>

    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:501: in __gt__
    return greater(self, asarray(other))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

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_dataarray.TestDataArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

All 6 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.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
ValueError: operands could not be broadcast together with shapes (2,2,2,5) (2,)
self = <xarray.tests.test_dataarray.TestDataArray object at 0x7f32559041d0>

    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/home/runner/work/xarray/xarray/xarray/tests/test_dataarray.py#x1B[0m:860: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#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: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/home/runner/work/xarray/xarray/xarray/namedarray/_array_api/_elementwise_functions.py#x1B[0m:178: 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 6 runs failed: test_sel (xarray.tests.test_dataarray.TestDataArray)

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
TypeError: asarray() got an unexpected keyword argument 'device'
self = <xarray.tests.test_dataarray.TestDataArray object at 0x7fce2dccfb20>

    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:533: in __lt__
    return less(self, asarray(other))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

obj = 4

    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_dataarray.TestDataArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 6 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
TypeError: asarray() got an unexpected keyword argument 'device'
self = <xarray.tests.test_dataarray.TestDataArray object at 0x7fce2dccbee0>

    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:533: in __lt__
    return less(self, asarray(other))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

obj = 5

    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_dataarray.TestDataArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

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

artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
TypeError: asarray() got an unexpected keyword argument 'device'
self = <xarray.tests.test_dataarray.TestDataArray object at 0x7fce2dcca620>

    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:533: in __lt__
    return less(self, asarray(other))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

obj = 4

    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_dataarray.TestDataArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 6 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
TypeError: asarray() got an unexpected keyword argument 'device'
self = <xarray.tests.test_dataarray.TestDataArray object at 0x7fce2dccafe0>

    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:469: in __eq__
    return equal(self, asarray(other))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

obj = 0

    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_dataarray.TestDataArray

See this annotation in the file changed.

@github-actions github-actions / Test Results

1 out of 6 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
TypeError: asarray() got an unexpected keyword argument 'device'
self = <xarray.tests.test_dataarray.TestDataArray object at 0x7fce2dcc98d0>

    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:533: in __lt__
    return less(self, asarray(other))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

obj = 4

    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_calendar_ops

See this annotation in the file changed.

@github-actions github-actions / Test Results

All 5 runs failed: test_convert_calendar_360_days[year-standard-360_day-D] (xarray.tests.test_calendar_ops)

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
ValueError: dimensions () must have the same length as the number of data dimensions, ndim=1
source = 'standard', target = '360_day', freq = 'D', align_on = 'year'

    @pytest.mark.parametrize(
        "source,target,freq",
        [
            ("standard", "360_day", "D"),
            ("360_day", "proleptic_gregorian", "D"),
            ("proleptic_gregorian", "360_day", "4h"),
        ],
    )
    @pytest.mark.parametrize("align_on", ["date", "year"])
    def test_convert_calendar_360_days(source, target, freq, align_on):
        src = DataArray(
            date_range("2004-01-01", "2004-12-30", freq=freq, calendar=source),
            dims=("time",),
            name="time",
        )
        da_src = DataArray(
            np.linspace(0, 1, src.size), dims=("time",), coords={"time": src}
        )
    
>       conv = convert_calendar(da_src, target, align_on=align_on)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_calendar_ops.py#x1B[0m:85: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/coding/calendar_ops.py#x1B[0m:194: in convert_calendar
    new_doy = time.groupby(f"{dim}.year").map(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/groupby.py#x1B[0m:1156: in map
    return self._combine(applied, shortcut=shortcut)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/groupby.py#x1B[0m:1175: in _combine
    applied_example, applied = peek_at(applied)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/utils.py#x1B[0m:199: in peek_at
    peek = next(gen)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/groupby.py#x1B[0m:1155: in <genexpr>
    applied = (maybe_wrap_array(arr, func(arr, *args, **kwargs)) for arr in grouped)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/coding/calendar_ops.py#x1B[0m:252: in _interpolate_day_of_year
    _days_in_year(year, target_calendar, use_cftime)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:311: in __rmul__
    return self._binary_op(other, operator.mul, reflexive=True)
#x1B[1m#x1B[31m/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:680: in __rmul__
    return multiply(asarray(other), self)
#x1B[1m#x1B[31m/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:322: in _new
    return _new(self, dims, data, attrs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:157: in _new
    return cls_(dims_, data, attrs_)
#x1B[1m#x1B[31m/home/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 0x7f393610b400>
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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:886: ValueError

Check warning on line 0 in xarray.tests.test_calendar_ops

See this annotation in the file changed.

@github-actions github-actions / Test Results

All 5 runs failed: test_convert_calendar_360_days[year-360_day-proleptic_gregorian-D] (xarray.tests.test_calendar_ops)

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
ValueError: dimensions () must have the same length as the number of data dimensions, ndim=1
source = '360_day', target = 'proleptic_gregorian', freq = 'D'
align_on = 'year'

    @pytest.mark.parametrize(
        "source,target,freq",
        [
            ("standard", "360_day", "D"),
            ("360_day", "proleptic_gregorian", "D"),
            ("proleptic_gregorian", "360_day", "4h"),
        ],
    )
    @pytest.mark.parametrize("align_on", ["date", "year"])
    def test_convert_calendar_360_days(source, target, freq, align_on):
        src = DataArray(
            date_range("2004-01-01", "2004-12-30", freq=freq, calendar=source),
            dims=("time",),
            name="time",
        )
        da_src = DataArray(
            np.linspace(0, 1, src.size), dims=("time",), coords={"time": src}
        )
    
>       conv = convert_calendar(da_src, target, align_on=align_on)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_calendar_ops.py#x1B[0m:85: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/coding/calendar_ops.py#x1B[0m:194: in convert_calendar
    new_doy = time.groupby(f"{dim}.year").map(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/groupby.py#x1B[0m:1156: in map
    return self._combine(applied, shortcut=shortcut)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/groupby.py#x1B[0m:1175: in _combine
    applied_example, applied = peek_at(applied)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/utils.py#x1B[0m:199: in peek_at
    peek = next(gen)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/groupby.py#x1B[0m:1155: in <genexpr>
    applied = (maybe_wrap_array(arr, func(arr, *args, **kwargs)) for arr in grouped)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/coding/calendar_ops.py#x1B[0m:252: in _interpolate_day_of_year
    _days_in_year(year, target_calendar, use_cftime)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:311: in __rmul__
    return self._binary_op(other, operator.mul, reflexive=True)
#x1B[1m#x1B[31m/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:680: in __rmul__
    return multiply(asarray(other), self)
#x1B[1m#x1B[31m/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:322: in _new
    return _new(self, dims, data, attrs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:157: in _new
    return cls_(dims_, data, attrs_)
#x1B[1m#x1B[31m/home/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 0x7f39345cb840>
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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:886: ValueError

Check warning on line 0 in xarray.tests.test_calendar_ops

See this annotation in the file changed.

@github-actions github-actions / Test Results

All 5 runs failed: test_convert_calendar_360_days[year-proleptic_gregorian-360_day-4h] (xarray.tests.test_calendar_ops)

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
ValueError: dimensions () must have the same length as the number of data dimensions, ndim=1
source = 'proleptic_gregorian', target = '360_day', freq = '4h'
align_on = 'year'

    @pytest.mark.parametrize(
        "source,target,freq",
        [
            ("standard", "360_day", "D"),
            ("360_day", "proleptic_gregorian", "D"),
            ("proleptic_gregorian", "360_day", "4h"),
        ],
    )
    @pytest.mark.parametrize("align_on", ["date", "year"])
    def test_convert_calendar_360_days(source, target, freq, align_on):
        src = DataArray(
            date_range("2004-01-01", "2004-12-30", freq=freq, calendar=source),
            dims=("time",),
            name="time",
        )
        da_src = DataArray(
            np.linspace(0, 1, src.size), dims=("time",), coords={"time": src}
        )
    
>       conv = convert_calendar(da_src, target, align_on=align_on)

#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_calendar_ops.py#x1B[0m:85: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/coding/calendar_ops.py#x1B[0m:194: in convert_calendar
    new_doy = time.groupby(f"{dim}.year").map(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/groupby.py#x1B[0m:1156: in map
    return self._combine(applied, shortcut=shortcut)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/groupby.py#x1B[0m:1175: in _combine
    applied_example, applied = peek_at(applied)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/utils.py#x1B[0m:199: in peek_at
    peek = next(gen)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/groupby.py#x1B[0m:1155: in <genexpr>
    applied = (maybe_wrap_array(arr, func(arr, *args, **kwargs)) for arr in grouped)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/coding/calendar_ops.py#x1B[0m:252: in _interpolate_day_of_year
    _days_in_year(year, target_calendar, use_cftime)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:311: in __rmul__
    return self._binary_op(other, operator.mul, reflexive=True)
#x1B[1m#x1B[31m/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:680: in __rmul__
    return multiply(asarray(other), self)
#x1B[1m#x1B[31m/home/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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:322: in _new
    return _new(self, dims, data, attrs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:157: in _new
    return cls_(dims_, data, attrs_)
#x1B[1m#x1B[31m/home/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 0x7f3935db8a80>
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/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:886: ValueError