Add support for Array API in NamedArray #3
66 errors, 3 142 fail, 7 888 skipped, 2 524 pass in 7m 33s
Annotations
github-actions / Test Results
1 out of 2 runs with error: xarray.tests.test_dask
artifacts/Test results for Linux-3.12 flaky/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/core/_typed_ops.py#x1B[0m:483: in __mul__
return self._binary_op(other, operator.mul)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:2318: in _binary_op
self_data, other_data, dims = _broadcast_compat_data(self, other)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:2928: in _broadcast_compat_data
new_self, new_other = _broadcast_compat_variables(self, other)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:2895: in _broadcast_compat_variables
return tuple(var.set_dims(dims) if var.dims != dims else var for var in variables)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:2895: in <genexpr>
return tuple(var.set_dims(dims) if var.dims != dims else var for var in variables)
#x1B[1m#x1B[31mxarray/util/deprecation_helpers.py#x1B[0m:141: in wrapper
return func(*args, **kwargs)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:1389: in set_dims
return expanded_var.transpose(*dim)
#x1B[1m#x1B[31mxarray/util/deprecation_helpers.py#x1B[0m:141: in wrapper
return func(*args, **kwargs)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:1332: in transpose
axes = self.get_axis_num(dim)
#x1B[1m#x1B[31mxarray/namedarray/core.py#x1B[0m:799: in get_axis_num
if dims is _default:
#x1B[1m#x1B[31mE NameError: name 'dims' is not defined#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/core/_typed_ops.py#x1B[0m:483: in __mul__
return self._binary_op(other, operator.mul)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:2318: in _binary_op
self_data, other_data, dims = _broadcast_compat_data(self, other)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:2928: in _broadcast_compat_data
new_self, new_other = _broadcast_compat_variables(self, other)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:2895: in _broadcast_compat_variables
return tuple(var.set_dims(dims) if var.dims != dims else var for var in variables)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:2895: in <genexpr>
return tuple(var.set_dims(dims) if var.dims != dims else var for var in variables)
#x1B[1m#x1B[31mxarray/util/deprecation_helpers.py#x1B[0m:141: in wrapper
return func(*args, **kwargs)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:1389: in set_dims
return expanded_var.transpose(*dim)
#x1B[1m#x1B[31mxarray/util/deprecation_helpers.py#x1B[0m:141: in wrapper
return func(*args, **kwargs)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:1332: in transpose
axes = self.get_axis_num(dim)
#x1B[1m#x1B[31mxarray/namedarray/core.py#x1B[0m:799: in get_axis_num
if dims is _default:
#x1B[1m#x1B[31mE NameError: name 'dims' is not defined#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/core/_typed_ops.py#x1B[0m:483: in __mul__
return self._binary_op(other, operator.mul)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:2318: in _binary_op
self_data, other_data, dims = _broadcast_compat_data(self, other)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:2928: in _broadcast_compat_data
new_self, new_other = _broadcast_compat_variables(self, other)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:2895: in _broadcast_compat_variables
return tuple(var.set_dims(dims) if var.dims != dims else var for var in variables)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:2895: in <genexpr>
return tuple(var.set_dims(dims) if var.dims != dims else var for var in variables)
#x1B[1m#x1B[31mxarray/util/deprecation_helpers.py#x1B[0m:141: in wrapper
return func(*args, **kwargs)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:1389: in set_dims
return expanded_var.transpose(*dim)
#x1B[1m#x1B[31mxarray/util/deprecation_helpers.py#x1B[0m:141: in wrapper
return func(*args, **kwargs)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:1332: in transpose
axes = self.get_axis_num(dim)
#x1B[1m#x1B[31mxarray/namedarray/core.py#x1B[0m:799: in get_axis_num
if dims is _default:
#x1B[1m#x1B[31mE NameError: name 'dims' is not defined#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/core/_typed_ops.py#x1B[0m:483: in __mul__
return self._binary_op(other, operator.mul)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:2318: in _binary_op
self_data, other_data, dims = _broadcast_compat_data(self, other)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:2928: in _broadcast_compat_data
new_self, new_other = _broadcast_compat_variables(self, other)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:2895: in _broadcast_compat_variables
return tuple(var.set_dims(dims) if var.dims != dims else var for var in variables)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:2895: in <genexpr>
return tuple(var.set_dims(dims) if var.dims != dims else var for var in variables)
#x1B[1m#x1B[31mxarray/util/deprecation_helpers.py#x1B[0m:141: in wrapper
return func(*args, **kwargs)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:1389: in set_dims
return expanded_var.transpose(*dim)
#x1B[1m#x1B[31mxarray/util/deprecation_helpers.py#x1B[0m:141: in wrapper
return func(*args, **kwargs)
#x1B[1m#x1B[31mxarray/core/variable.py#x1B[0m:1332: in transpose
axes = self.get_axis_num(dim)
#x1B[1m#x1B[31mxarray/namedarray/core.py#x1B[0m:799: in get_axis_num
if dims is _default:
#x1B[1m#x1B[31mE NameError: name 'dims' is not defined#x1B[0m
Check warning on line 0 in xarray.tests.test_backends_api
github-actions / Test Results
test_multiindex (xarray.tests.test_backends_api) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
NameError: name 'dims' is not defined
def test_multiindex() -> None:
# GH7139
# Check that we properly handle backends that change index variables
dataset = xr.Dataset(coords={"coord1": ["A", "B"], "coord2": [1, 2]})
> dataset = dataset.stack(z=["coord1", "coord2"])
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_backends_api.py#x1B[0m:54:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/util/deprecation_helpers.py#x1B[0m:141: in wrapper
return func(*args, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:5411: in stack
result = result._stack_once(dims, new_dim, index_cls, create_index)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:5325: in _stack_once
exp_var = var.set_dims(vdims, shape)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/util/deprecation_helpers.py#x1B[0m:141: in wrapper
return func(*args, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1389: in set_dims
return expanded_var.transpose(*dim)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/util/deprecation_helpers.py#x1B[0m:141: in wrapper
return func(*args, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1332: in transpose
axes = self.get_axis_num(dim)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <xarray.Variable (coord2: 2, coord1: 2)> Size: 16B
array([['A', 'B'],
['A', 'B']], dtype='<U1')
dim = ('coord1', 'coord2')
def get_axis_num(self, dim: Hashable | Iterable[Hashable]) -> int | tuple[int, ...]:
"""Return axis number(s) corresponding to dimension(s) in this array.
Parameters
----------
dim : str or iterable of str
Dimension name(s) for which to lookup axes.
Returns
-------
int or tuple of int
Axis number or numbers corresponding to the given dimensions.
"""
> if dims is _default:
#x1B[1m#x1B[31mE NameError: name 'dims' is not defined#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:799: NameError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
test_contains_broadcast[str] (xarray.tests.test_accessor_str) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
dtype = <class 'numpy.str_'>
def test_contains_broadcast(dtype) -> None:
values = xr.DataArray(["Foo", "xYz", "fOOomMm__fOo", "MMM_"], dims="X").astype(
dtype
)
pat_str = xr.DataArray(["FOO|mmm", "Foo", "MMM"], dims="Y").astype(dtype)
pat_re = xr.DataArray([re.compile(x) for x in pat_str.data], dims="Y")
# case insensitive using regex
result = values.str.contains(pat_str, case=False)
expected = xr.DataArray(
[
[True, True, False],
[False, False, False],
[True, True, True],
[True, False, True],
],
dims=["X", "Y"],
)
assert result.dtype == expected.dtype
assert_equal(result, expected)
# case sensitive using regex
result = values.str.contains(pat_str)
expected = xr.DataArray(
[
[False, True, False],
[False, False, False],
[False, False, False],
[False, False, True],
],
dims=["X", "Y"],
)
assert result.dtype == expected.dtype
assert_equal(result, expected)
> result = values.str.contains(pat_re)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:181:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:1491: in contains
is_compiled_re = _contains_compiled_re(pat)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:104: in _contains_compiled_re
return _contains_obj_type(pat=pat, checker=re.Pattern)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:88: in _contains_obj_type
return _apply_str_ufunc(func=checker, obj=pat).all()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1358: in all
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (Y: 3)> Size: 24B
array([True, True, True], dtype=object)
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
test_contains_broadcast[bytes] (xarray.tests.test_accessor_str) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
dtype = <class 'numpy.bytes_'>
def test_contains_broadcast(dtype) -> None:
values = xr.DataArray(["Foo", "xYz", "fOOomMm__fOo", "MMM_"], dims="X").astype(
dtype
)
pat_str = xr.DataArray(["FOO|mmm", "Foo", "MMM"], dims="Y").astype(dtype)
pat_re = xr.DataArray([re.compile(x) for x in pat_str.data], dims="Y")
# case insensitive using regex
result = values.str.contains(pat_str, case=False)
expected = xr.DataArray(
[
[True, True, False],
[False, False, False],
[True, True, True],
[True, False, True],
],
dims=["X", "Y"],
)
assert result.dtype == expected.dtype
assert_equal(result, expected)
# case sensitive using regex
result = values.str.contains(pat_str)
expected = xr.DataArray(
[
[False, True, False],
[False, False, False],
[False, False, False],
[False, False, True],
],
dims=["X", "Y"],
)
assert result.dtype == expected.dtype
assert_equal(result, expected)
> result = values.str.contains(pat_re)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:181:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:1491: in contains
is_compiled_re = _contains_compiled_re(pat)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:104: in _contains_compiled_re
return _contains_obj_type(pat=pat, checker=re.Pattern)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:88: in _contains_obj_type
return _apply_str_ufunc(func=checker, obj=pat).all()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1358: in all
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (Y: 3)> Size: 24B
array([True, True, True], dtype=object)
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
test_replace_callable (xarray.tests.test_accessor_str) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
def test_replace_callable() -> None:
values = xr.DataArray(["fooBAD__barBAD"])
# test with callable
repl = lambda m: m.group(0).swapcase()
result = values.str.replace("[a-z][A-Z]{2}", repl, n=2)
exp = xr.DataArray(["foObaD__baRbaD"])
assert result.dtype == exp.dtype
assert_equal(result, exp)
# test regex named groups
values = xr.DataArray(["Foo Bar Baz"])
pat = r"(?P<first>\w+) (?P<middle>\w+) (?P<last>\w+)"
repl = lambda m: m.group("middle").swapcase()
result = values.str.replace(pat, repl)
exp = xr.DataArray(["bAR"])
assert result.dtype == exp.dtype
assert_equal(result, exp)
# test broadcast
values = xr.DataArray(["Foo Bar Baz"], dims=["x"])
pat = r"(?P<first>\w+) (?P<middle>\w+) (?P<last>\w+)"
repl2 = xr.DataArray(
[
lambda m: m.group("first").swapcase(),
lambda m: m.group("middle").swapcase(),
lambda m: m.group("last").swapcase(),
],
dims=["Y"],
)
> result = values.str.replace(pat, repl2)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:417:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:1931: in replace
elif not _contains_callable(repl): # pragma: no cover
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:109: in _contains_callable
return _contains_obj_type(pat=pat, checker=callable)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:88: in _contains_obj_type
return _apply_str_ufunc(func=checker, obj=pat).all()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1358: in all
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (Y: 3)> Size: 24B
array([True, True, True], dtype=object)
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
test_replace_unicode (xarray.tests.test_accessor_str) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
def test_replace_unicode() -> None:
# flags + unicode
values = xr.DataArray([b"abcd,\xc3\xa0".decode("utf-8")])
expected = xr.DataArray([b"abcd, \xc3\xa0".decode("utf-8")])
pat = re.compile(r"(?<=\w),(?=\w)", flags=re.UNICODE)
result = values.str.replace(pat, ", ")
assert result.dtype == expected.dtype
assert_equal(result, expected)
# broadcast version
values = xr.DataArray([b"abcd,\xc3\xa0".decode("utf-8")], dims=["X"])
expected = xr.DataArray(
[[b"abcd, \xc3\xa0".decode("utf-8"), b"BAcd,\xc3\xa0".decode("utf-8")]],
dims=["X", "Y"],
)
pat2 = xr.DataArray(
[re.compile(r"(?<=\w),(?=\w)", flags=re.UNICODE), r"ab"], dims=["Y"]
)
repl = xr.DataArray([", ", "BA"], dims=["Y"])
> result = values.str.replace(pat2, repl)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:442:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:1934: in replace
is_compiled_re = _contains_compiled_re(pat)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:104: in _contains_compiled_re
return _contains_obj_type(pat=pat, checker=re.Pattern)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:88: in _contains_obj_type
return _apply_str_ufunc(func=checker, obj=pat).all()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1358: in all
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (Y: 2)> Size: 16B
array([True, False], dtype=object)
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError
Check warning on line 0 in xarray.tests.test_coarsen
github-actions / Test Results
test_coarsen_da_reduce[numpy-sum-1-1] (xarray.tests.test_coarsen) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
da = <xarray.DataArray (a: 3, time: 21, x: 4)> Size: 2kB
array([[[0.5488135 , 0.71518937, 0.60276338, 0.54488318],
...ates:
* time (time) datetime64[ns] 168B 2000-01-01 2000-01-02 ... 2000-01-21
Dimensions without coordinates: a, x
window = 1, name = 'sum'
@pytest.mark.parametrize("da", (1, 2), indirect=True)
@pytest.mark.parametrize("window", (1, 2, 3, 4))
@pytest.mark.parametrize("name", ("sum", "mean", "std", "max"))
def test_coarsen_da_reduce(da, window, name) -> None:
> if da.isnull().sum() > 1 and window == 1:
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_coarsen.py#x1B[0m:244:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1857: in sum
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (a: 3, time: 21, x: 4)> Size: 252B
array([[[False, False, False, False],
[False, False, False...e],
[False, False, False, False],
[False, False, False, False],
[False, False, False, False]]])
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError
Check warning on line 0 in xarray.tests.test_dataset.TestDataset
github-actions / Test Results
test_selection_multiindex (xarray.tests.test_dataset.TestDataset) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
NameError: name 'dims' is not defined
self = <xarray.tests.test_dataset.TestDataset object at 0x7f9c21d18c40>
def test_selection_multiindex(self) -> None:
midx = pd.MultiIndex.from_product(
[["a", "b"], [1, 2], [-1, -2]], names=("one", "two", "three")
)
midx_coords = Coordinates.from_pandas_multiindex(midx, "x")
mdata = Dataset(data_vars={"var": ("x", range(8))}, coords=midx_coords)
def test_sel(
lab_indexer, pos_indexer, replaced_idx=False, renamed_dim=None
) -> None:
ds = mdata.sel(x=lab_indexer)
expected_ds = mdata.isel(x=pos_indexer)
if not replaced_idx:
assert_identical(ds, expected_ds)
else:
if renamed_dim:
assert ds["var"].dims[0] == renamed_dim
ds = ds.rename({renamed_dim: "x"})
assert_identical(ds["var"].variable, expected_ds["var"].variable)
assert not ds["x"].equals(expected_ds["x"])
test_sel(("a", 1, -1), 0)
test_sel(("b", 2, -2), -1)
> test_sel(("a", 1), [0, 1], replaced_idx=True, renamed_dim="three")
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_dataset.py#x1B[0m:2067:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_dataset.py#x1B[0m:2054: in test_sel
ds = mdata.sel(x=lab_indexer)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:3192: in sel
result = self.isel(indexers=query_results.dim_indexers, drop=drop)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:3044: in isel
var = var.isel(var_indexers)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1034: in isel
return self[key]
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:798: in __getitem__
dims, indexer, new_order = self._broadcast_indexes(key)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:638: in _broadcast_indexes
self._validate_indexers(key)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:679: in _validate_indexers
if self.shape[self.get_axis_num(dim)] != len(k):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <xarray.Variable (x: 8)> Size: 64B
array([0, 1, 2, 3, 4, 5, 6, 7])
dim = 'x'
def get_axis_num(self, dim: Hashable | Iterable[Hashable]) -> int | tuple[int, ...]:
"""Return axis number(s) corresponding to dimension(s) in this array.
Parameters
----------
dim : str or iterable of str
Dimension name(s) for which to lookup axes.
Returns
-------
int or tuple of int
Axis number or numbers corresponding to the given dimensions.
"""
> if dims is _default:
#x1B[1m#x1B[31mE NameError: name 'dims' is not defined#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:799: NameError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
test_replace_compiled_regex[str] (xarray.tests.test_accessor_str) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
dtype = <class 'numpy.str_'>
def test_replace_compiled_regex(dtype) -> None:
values = xr.DataArray(["fooBAD__barBAD"], dims=["x"]).astype(dtype)
# test with compiled regex
pat = re.compile(dtype("BAD[_]*"))
result = values.str.replace(pat, "")
expected = xr.DataArray(["foobar"], dims=["x"]).astype(dtype)
assert result.dtype == expected.dtype
assert_equal(result, expected)
result = values.str.replace(pat, "", n=1)
expected = xr.DataArray(["foobarBAD"], dims=["x"]).astype(dtype)
assert result.dtype == expected.dtype
assert_equal(result, expected)
# broadcast
pat2 = xr.DataArray(
[re.compile(dtype("BAD[_]*")), re.compile(dtype("AD[_]*"))], dims=["y"]
)
> result = values.str.replace(pat2, "")
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:466:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:1934: in replace
is_compiled_re = _contains_compiled_re(pat)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:104: in _contains_compiled_re
return _contains_obj_type(pat=pat, checker=re.Pattern)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:88: in _contains_obj_type
return _apply_str_ufunc(func=checker, obj=pat).all()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1358: in all
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (y: 2)> Size: 16B
array([True, True], dtype=object)
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError
Check warning on line 0 in xarray.tests.test_coarsen
github-actions / Test Results
test_coarsen_da_reduce[numpy-sum-1-2] (xarray.tests.test_coarsen) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
da = <xarray.DataArray (time: 11)> Size: 88B
array([ 0., nan, 1., 2., nan, 3., 4., 5., nan, 6., 7.])
Dimensions without coordinates: time
window = 1, name = 'sum'
@pytest.mark.parametrize("da", (1, 2), indirect=True)
@pytest.mark.parametrize("window", (1, 2, 3, 4))
@pytest.mark.parametrize("name", ("sum", "mean", "std", "max"))
def test_coarsen_da_reduce(da, window, name) -> None:
> if da.isnull().sum() > 1 and window == 1:
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_coarsen.py#x1B[0m:244:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1857: in sum
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (time: 11)> Size: 11B
array([False, True, False, False, True, False, False, False, True,
False, False])
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError
Check warning on line 0 in xarray.tests.test_coarsen
github-actions / Test Results
test_coarsen_da_reduce[numpy-sum-2-1] (xarray.tests.test_coarsen) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
da = <xarray.DataArray (a: 3, time: 21, x: 4)> Size: 2kB
array([[[0.5488135 , 0.71518937, 0.60276338, 0.54488318],
...ates:
* time (time) datetime64[ns] 168B 2000-01-01 2000-01-02 ... 2000-01-21
Dimensions without coordinates: a, x
window = 2, name = 'sum'
@pytest.mark.parametrize("da", (1, 2), indirect=True)
@pytest.mark.parametrize("window", (1, 2, 3, 4))
@pytest.mark.parametrize("name", ("sum", "mean", "std", "max"))
def test_coarsen_da_reduce(da, window, name) -> None:
> if da.isnull().sum() > 1 and window == 1:
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_coarsen.py#x1B[0m:244:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1857: in sum
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (a: 3, time: 21, x: 4)> Size: 252B
array([[[False, False, False, False],
[False, False, False...e],
[False, False, False, False],
[False, False, False, False],
[False, False, False, False]]])
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
test_replace_compiled_regex[bytes] (xarray.tests.test_accessor_str) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
dtype = <class 'numpy.bytes_'>
def test_replace_compiled_regex(dtype) -> None:
values = xr.DataArray(["fooBAD__barBAD"], dims=["x"]).astype(dtype)
# test with compiled regex
pat = re.compile(dtype("BAD[_]*"))
result = values.str.replace(pat, "")
expected = xr.DataArray(["foobar"], dims=["x"]).astype(dtype)
assert result.dtype == expected.dtype
assert_equal(result, expected)
result = values.str.replace(pat, "", n=1)
expected = xr.DataArray(["foobarBAD"], dims=["x"]).astype(dtype)
assert result.dtype == expected.dtype
assert_equal(result, expected)
# broadcast
pat2 = xr.DataArray(
[re.compile(dtype("BAD[_]*")), re.compile(dtype("AD[_]*"))], dims=["y"]
)
> result = values.str.replace(pat2, "")
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:466:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:1934: in replace
is_compiled_re = _contains_compiled_re(pat)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:104: in _contains_compiled_re
return _contains_obj_type(pat=pat, checker=re.Pattern)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:88: in _contains_obj_type
return _apply_str_ufunc(func=checker, obj=pat).all()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1358: in all
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (y: 2)> Size: 16B
array([True, True], dtype=object)
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError
Check warning on line 0 in xarray.tests.test_coarsen
github-actions / Test Results
test_coarsen_da_reduce[numpy-sum-2-2] (xarray.tests.test_coarsen) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
da = <xarray.DataArray (time: 11)> Size: 88B
array([ 0., nan, 1., 2., nan, 3., 4., 5., nan, 6., 7.])
Dimensions without coordinates: time
window = 2, name = 'sum'
@pytest.mark.parametrize("da", (1, 2), indirect=True)
@pytest.mark.parametrize("window", (1, 2, 3, 4))
@pytest.mark.parametrize("name", ("sum", "mean", "std", "max"))
def test_coarsen_da_reduce(da, window, name) -> None:
> if da.isnull().sum() > 1 and window == 1:
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_coarsen.py#x1B[0m:244:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1857: in sum
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (time: 11)> Size: 11B
array([False, True, False, False, True, False, False, False, True,
False, False])
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError
Check warning on line 0 in xarray.tests.test_coarsen
github-actions / Test Results
test_coarsen_da_reduce[numpy-sum-3-1] (xarray.tests.test_coarsen) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
da = <xarray.DataArray (a: 3, time: 21, x: 4)> Size: 2kB
array([[[0.5488135 , 0.71518937, 0.60276338, 0.54488318],
...ates:
* time (time) datetime64[ns] 168B 2000-01-01 2000-01-02 ... 2000-01-21
Dimensions without coordinates: a, x
window = 3, name = 'sum'
@pytest.mark.parametrize("da", (1, 2), indirect=True)
@pytest.mark.parametrize("window", (1, 2, 3, 4))
@pytest.mark.parametrize("name", ("sum", "mean", "std", "max"))
def test_coarsen_da_reduce(da, window, name) -> None:
> if da.isnull().sum() > 1 and window == 1:
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_coarsen.py#x1B[0m:244:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1857: in sum
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (a: 3, time: 21, x: 4)> Size: 252B
array([[[False, False, False, False],
[False, False, False...e],
[False, False, False, False],
[False, False, False, False],
[False, False, False, False]]])
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError
Check warning on line 0 in xarray.tests.test_dataset.TestDataset
github-actions / Test Results
test_broadcast_like (xarray.tests.test_dataset.TestDataset) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
NameError: name 'dims' is not defined
self = <xarray.tests.test_dataset.TestDataset object at 0x7f9c21d189d0>
def test_broadcast_like(self) -> None:
original1 = DataArray(
np.random.randn(5), [("x", range(5))], name="a"
).to_dataset()
original2 = DataArray(np.random.randn(6), [("y", range(6))], name="b")
> expected1, expected2 = broadcast(original1, original2)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_dataset.py#x1B[0m:2091:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/alignment.py#x1B[0m:1215: in broadcast
result = [_broadcast_helper(arg, exclude, dims_map, common_coords) for arg in args]
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/alignment.py#x1B[0m:1215: in <listcomp>
result = [_broadcast_helper(arg, exclude, dims_map, common_coords) for arg in args]
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/alignment.py#x1B[0m:1085: in _broadcast_helper
return cast(T_Alignable, _broadcast_dataset(arg))
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/alignment.py#x1B[0m:1076: in _broadcast_dataset
data_vars = {k: _set_dims(ds.variables[k]) for k in ds.data_vars}
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/alignment.py#x1B[0m:1076: in <dictcomp>
data_vars = {k: _set_dims(ds.variables[k]) for k in ds.data_vars}
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/alignment.py#x1B[0m:1065: in _set_dims
return var.set_dims(var_dims_map)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/util/deprecation_helpers.py#x1B[0m:141: in wrapper
return func(*args, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1389: in set_dims
return expanded_var.transpose(*dim)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/util/deprecation_helpers.py#x1B[0m:141: in wrapper
return func(*args, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1332: in transpose
axes = self.get_axis_num(dim)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <xarray.Variable (y: 6, x: 5)> Size: 240B
array([[1.76405235, 0.40015721, 0.97873798, 2.2408932 , 1.86755799],
... 0.40015721, 0.97873798, 2.2408932 , 1.86755799],
[1.76405235, 0.40015721, 0.97873798, 2.2408932 , 1.86755799]])
dim = ('x', 'y')
def get_axis_num(self, dim: Hashable | Iterable[Hashable]) -> int | tuple[int, ...]:
"""Return axis number(s) corresponding to dimension(s) in this array.
Parameters
----------
dim : str or iterable of str
Dimension name(s) for which to lookup axes.
Returns
-------
int or tuple of int
Axis number or numbers corresponding to the given dimensions.
"""
> if dims is _default:
#x1B[1m#x1B[31mE NameError: name 'dims' is not defined#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:799: NameError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
test_extract_extractall_findall_empty_raises[str] (xarray.tests.test_accessor_str) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
dtype = <class 'numpy.str_'>
def test_extract_extractall_findall_empty_raises(dtype) -> None:
pat_str = dtype(r".*")
pat_re = re.compile(pat_str)
value = xr.DataArray([["a"]], dims=["X", "Y"]).astype(dtype)
with pytest.raises(ValueError, match="No capture groups found in pattern."):
value.str.extract(pat=pat_str, dim="ZZ")
with pytest.raises(ValueError, match="No capture groups found in pattern."):
value.str.extract(pat=pat_re, dim="ZZ")
with pytest.raises(ValueError, match="No capture groups found in pattern."):
> value.str.extractall(pat=pat_str, group_dim="XX", match_dim="YY")
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:565:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:2236: in extractall
.max()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1502: in max
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (X: 1, Y: 1)> Size: 8B
array([[2]])
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError
Check warning on line 0 in xarray.tests.test_coarsen
github-actions / Test Results
test_coarsen_da_reduce[numpy-sum-3-2] (xarray.tests.test_coarsen) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
da = <xarray.DataArray (time: 11)> Size: 88B
array([ 0., nan, 1., 2., nan, 3., 4., 5., nan, 6., 7.])
Dimensions without coordinates: time
window = 3, name = 'sum'
@pytest.mark.parametrize("da", (1, 2), indirect=True)
@pytest.mark.parametrize("window", (1, 2, 3, 4))
@pytest.mark.parametrize("name", ("sum", "mean", "std", "max"))
def test_coarsen_da_reduce(da, window, name) -> None:
> if da.isnull().sum() > 1 and window == 1:
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_coarsen.py#x1B[0m:244:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1857: in sum
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (time: 11)> Size: 11B
array([False, True, False, False, True, False, False, False, True,
False, False])
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError
Check warning on line 0 in xarray.tests.test_coarsen
github-actions / Test Results
test_coarsen_da_reduce[numpy-sum-4-1] (xarray.tests.test_coarsen) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
da = <xarray.DataArray (a: 3, time: 21, x: 4)> Size: 2kB
array([[[0.5488135 , 0.71518937, 0.60276338, 0.54488318],
...ates:
* time (time) datetime64[ns] 168B 2000-01-01 2000-01-02 ... 2000-01-21
Dimensions without coordinates: a, x
window = 4, name = 'sum'
@pytest.mark.parametrize("da", (1, 2), indirect=True)
@pytest.mark.parametrize("window", (1, 2, 3, 4))
@pytest.mark.parametrize("name", ("sum", "mean", "std", "max"))
def test_coarsen_da_reduce(da, window, name) -> None:
> if da.isnull().sum() > 1 and window == 1:
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_coarsen.py#x1B[0m:244:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1857: in sum
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (a: 3, time: 21, x: 4)> Size: 252B
array([[[False, False, False, False],
[False, False, False...e],
[False, False, False, False],
[False, False, False, False],
[False, False, False, False]]])
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
test_extract_extractall_findall_empty_raises[bytes] (xarray.tests.test_accessor_str) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
dtype = <class 'numpy.bytes_'>
def test_extract_extractall_findall_empty_raises(dtype) -> None:
pat_str = dtype(r".*")
pat_re = re.compile(pat_str)
value = xr.DataArray([["a"]], dims=["X", "Y"]).astype(dtype)
with pytest.raises(ValueError, match="No capture groups found in pattern."):
value.str.extract(pat=pat_str, dim="ZZ")
with pytest.raises(ValueError, match="No capture groups found in pattern."):
value.str.extract(pat=pat_re, dim="ZZ")
with pytest.raises(ValueError, match="No capture groups found in pattern."):
> value.str.extractall(pat=pat_str, group_dim="XX", match_dim="YY")
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:565:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:2236: in extractall
.max()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1502: in max
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (X: 1, Y: 1)> Size: 8B
array([[2]])
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError
Check warning on line 0 in xarray.tests.test_combine.TestCombineND
github-actions / Test Results
test_concat_once[dim1] (xarray.tests.test_combine.TestCombineND) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
NameError: name 'dims' is not defined
self = <xarray.tests.test_combine.TestCombineND object at 0x7f0c276cc580>
create_combined_ids = <function _create_combined_ids at 0x7f0c27bd00d0>
concat_dim = 'dim1'
@pytest.mark.parametrize("concat_dim", ["dim1", "new_dim"])
def test_concat_once(self, create_combined_ids, concat_dim):
shape = (2,)
combined_ids = create_combined_ids(shape)
ds = create_test_data
> result = _combine_all_along_first_dim(
combined_ids,
dim=concat_dim,
data_vars="all",
coords="different",
compat="no_conflicts",
)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_combine.py#x1B[0m:284:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/combine.py#x1B[0m:269: in _combine_all_along_first_dim
new_combined_ids[new_id] = _combine_1d(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/combine.py#x1B[0m:292: in _combine_1d
combined = concat(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/concat.py#x1B[0m:277: in concat
return _dataset_concat(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/concat.py#x1B[0m:667: in _dataset_concat
combined_var = concat_vars(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:2992: in concat
return Variable.concat(variables, dim, positions, shortcut, combine_attrs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1741: in concat
axis = first_var.get_axis_num(dim)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <xarray.Variable (dim1: 8, dim2: 9)> Size: 576B
array([[ 1.76405235, 0.40015721, 0.97873798, 2.2408932 , 1.8675579...63019835, 0.46278226,
-0.90729836, 0.0519454 , 0.72909056, 0.12898291]])
Attributes:
foo: variable
dim = 'dim1'
def get_axis_num(self, dim: Hashable | Iterable[Hashable]) -> int | tuple[int, ...]:
"""Return axis number(s) corresponding to dimension(s) in this array.
Parameters
----------
dim : str or iterable of str
Dimension name(s) for which to lookup axes.
Returns
-------
int or tuple of int
Axis number or numbers corresponding to the given dimensions.
"""
> if dims is _default:
#x1B[1m#x1B[31mE NameError: name 'dims' is not defined#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:799: NameError
Check warning on line 0 in xarray.tests.test_coarsen
github-actions / Test Results
test_coarsen_da_reduce[numpy-sum-4-2] (xarray.tests.test_coarsen) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
da = <xarray.DataArray (time: 11)> Size: 88B
array([ 0., nan, 1., 2., nan, 3., 4., 5., nan, 6., 7.])
Dimensions without coordinates: time
window = 4, name = 'sum'
@pytest.mark.parametrize("da", (1, 2), indirect=True)
@pytest.mark.parametrize("window", (1, 2, 3, 4))
@pytest.mark.parametrize("name", ("sum", "mean", "std", "max"))
def test_coarsen_da_reduce(da, window, name) -> None:
> if da.isnull().sum() > 1 and window == 1:
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_coarsen.py#x1B[0m:244:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1857: in sum
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (time: 11)> Size: 11B
array([False, True, False, False, True, False, False, False, True,
False, False])
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError
Check warning on line 0 in xarray.tests.test_dataset.TestDataset
github-actions / Test Results
test_align (xarray.tests.test_dataset.TestDataset) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
self = <xarray.tests.test_dataset.TestDataset object at 0x7f9c21d044c0>
def test_align(self) -> None:
left = create_test_data()
right = left.copy(deep=True)
right["dim3"] = ("dim3", list("cdefghijkl"))
right["var3"][:-2] = right["var3"][2:].values
right["var3"][-2:] = np.random.randn(*right["var3"][-2:].shape)
right["numbers"][:-2] = right["numbers"][2:].values
right["numbers"][-2:] = -10
intersection = list("cdefghij")
union = list("abcdefghijkl")
left2, right2 = align(left, right, join="inner")
assert_array_equal(left2["dim3"], intersection)
assert_identical(left2, right2)
left2, right2 = align(left, right, join="outer")
assert_array_equal(left2["dim3"], union)
assert_equal(left2["dim3"].variable, right2["dim3"].variable)
assert_identical(left2.sel(dim3=intersection), right2.sel(dim3=intersection))
> assert np.isnan(left2["var3"][-2:]).all()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_dataset.py#x1B[0m:2390:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1358: in all
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (dim3: 2, dim1: 8)> Size: 16B
array([[ True, True, True, True, True, True, True, True],
[ True, True, True, True, True, True, True, True]])
Attributes:
foo: variable
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError
Check warning on line 0 in xarray.tests.test_combine.TestCombineND
github-actions / Test Results
test_concat_once[new_dim] (xarray.tests.test_combine.TestCombineND) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
NameError: name 'dims' is not defined
self = <xarray.tests.test_combine.TestCombineND object at 0x7f0c276cc850>
create_combined_ids = <function _create_combined_ids at 0x7f0c27bd00d0>
concat_dim = 'new_dim'
@pytest.mark.parametrize("concat_dim", ["dim1", "new_dim"])
def test_concat_once(self, create_combined_ids, concat_dim):
shape = (2,)
combined_ids = create_combined_ids(shape)
ds = create_test_data
> result = _combine_all_along_first_dim(
combined_ids,
dim=concat_dim,
data_vars="all",
coords="different",
compat="no_conflicts",
)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_combine.py#x1B[0m:284:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/combine.py#x1B[0m:269: in _combine_all_along_first_dim
new_combined_ids[new_id] = _combine_1d(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/combine.py#x1B[0m:292: in _combine_1d
combined = concat(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/concat.py#x1B[0m:277: in concat
return _dataset_concat(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/concat.py#x1B[0m:667: in _dataset_concat
combined_var = concat_vars(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:2992: in concat
return Variable.concat(variables, dim, positions, shortcut, combine_attrs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1741: in concat
axis = first_var.get_axis_num(dim)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <xarray.Variable (new_dim: 1, dim1: 8, dim2: 9)> Size: 576B
array([[[ 1.76405235, 0.40015721, 0.97873798, 2.2408932... 0.46278226, -0.90729836, 0.0519454 , 0.72909056,
0.12898291]]])
Attributes:
foo: variable
dim = 'new_dim'
def get_axis_num(self, dim: Hashable | Iterable[Hashable]) -> int | tuple[int, ...]:
"""Return axis number(s) corresponding to dimension(s) in this array.
Parameters
----------
dim : str or iterable of str
Dimension name(s) for which to lookup axes.
Returns
-------
int or tuple of int
Axis number or numbers corresponding to the given dimensions.
"""
> if dims is _default:
#x1B[1m#x1B[31mE NameError: name 'dims' is not defined#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:799: NameError
Check warning on line 0 in xarray.tests.test_coarsen
github-actions / Test Results
test_coarsen_da_reduce[numpy-mean-1-1] (xarray.tests.test_coarsen) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
da = <xarray.DataArray (a: 3, time: 21, x: 4)> Size: 2kB
array([[[0.5488135 , 0.71518937, 0.60276338, 0.54488318],
...ates:
* time (time) datetime64[ns] 168B 2000-01-01 2000-01-02 ... 2000-01-21
Dimensions without coordinates: a, x
window = 1, name = 'mean'
@pytest.mark.parametrize("da", (1, 2), indirect=True)
@pytest.mark.parametrize("window", (1, 2, 3, 4))
@pytest.mark.parametrize("name", ("sum", "mean", "std", "max"))
def test_coarsen_da_reduce(da, window, name) -> None:
> if da.isnull().sum() > 1 and window == 1:
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_coarsen.py#x1B[0m:244:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1857: in sum
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (a: 3, time: 21, x: 4)> Size: 252B
array([[[False, False, False, False],
[False, False, False...e],
[False, False, False, False],
[False, False, False, False],
[False, False, False, False]]])
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
test_extract_broadcast[str] (xarray.tests.test_accessor_str) failed
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
dtype = <class 'numpy.str_'>
def test_extract_broadcast(dtype) -> None:
value = xr.DataArray(
["a_Xy_0", "ab_xY_10", "abc_Xy_01"],
dims=["X"],
).astype(dtype)
pat_str = xr.DataArray(
[r"(\w+)_Xy_(\d*)", r"(\w+)_xY_(\d*)"],
dims=["Y"],
).astype(dtype)
pat_compiled = value.str._re_compile(pat=pat_str)
expected_list = [
[["a", "0"], ["", ""]],
[["", ""], ["ab", "10"]],
[["abc", "01"], ["", ""]],
]
expected = xr.DataArray(expected_list, dims=["X", "Y", "Zz"]).astype(dtype)
> res_str = value.str.extract(pat=pat_str, dim="Zz")
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:862:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:2052: in extract
.max()
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1502: in max
return self.reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:3831: in reduce
var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1018: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (Y: 2)> Size: 16B
array([2, 2])
dims = (<Default.token: 0>,), axis = None
def _dims_to_axis(
x: NamedArray[Any, Any], dims: _Dim | _Dims | Default, axis: _AxisLike | None
) -> _AxisLike | None:
"""
Convert dims to axis indices.
Examples
--------
>>> narr = NamedArray(("x", "y"), np.array([[1, 2, 3], [5, 6, 7]]))
>>> _dims_to_axis(narr, ("y",), None)
(1,)
>>> _dims_to_axis(narr, None, 0)
(0,)
>>> _dims_to_axis(narr, None, None)
"""
_assert_either_dim_or_axis(dims, axis)
if dims is not _default:
> return x._dims_to_axes(dims)
#x1B[1m#x1B[31mE AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?#x1B[0m
#x1B[1m#x1B[31m/home/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:150: AttributeError