Add support for Array API in NamedArray #53
144 errors, 7 041 fail, 1 572 skipped, 10 965 pass in 2h 24m 16s
Annotations
github-actions / Test Results
8 out of 10 runs with error: xarray.tests.test_dask
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12 flaky/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
#x1B[31mImportError while importing test module '/home/runner/work/xarray/xarray/xarray/tests/test_dask.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
#x1B[1m#x1B[31m../../../micromamba/envs/xarray-tests/lib/python3.12/importlib/__init__.py#x1B[0m:90: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
#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:1059: in make_da
da.coords["ndcoord"] = da.x * 2
#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:676: in __mul__
from xarray.namedarray._array_api import multiply
#x1B[1m#x1B[31mxarray/namedarray/_array_api/__init__.py#x1B[0m:11: in <module>
from xarray.namedarray._array_api._constants import e, inf, nan, newaxis, pi
#x1B[1m#x1B[31mxarray/namedarray/_array_api/_constants.py#x1B[0m:3: in <module>
_xp = _maybe_default_namespace()
#x1B[1m#x1B[31mxarray/namedarray/_array_api/_utils.py#x1B[0m:22: in _maybe_default_namespace
import array_api_compat.numpy as xpd
#x1B[1m#x1B[31mE ModuleNotFoundError: No module named 'array_api_compat'#x1B[0m#x1B[0m
github-actions / Test Results
9 out of 10 runs with error: xarray.tests.test_sparse
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12 flaky/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
#x1B[31mImportError while importing test module '/home/runner/work/xarray/xarray/xarray/tests/test_sparse.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
#x1B[1m#x1B[31m../../../micromamba/envs/xarray-tests/lib/python3.12/importlib/__init__.py#x1B[0m:90: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
#x1B[1m#x1B[31mxarray/tests/test_sparse.py#x1B[0m:220: in <module>
(do("where", cond=make_xrvar({"x": 10, "y": 5}) > 0.5), True),
#x1B[1m#x1B[31mxarray/namedarray/core.py#x1B[0m:752: in __gt__
from xarray.namedarray._array_api import greater
#x1B[1m#x1B[31mxarray/namedarray/_array_api/__init__.py#x1B[0m:11: in <module>
from xarray.namedarray._array_api._constants import e, inf, nan, newaxis, pi
#x1B[1m#x1B[31mxarray/namedarray/_array_api/_constants.py#x1B[0m:3: in <module>
_xp = _maybe_default_namespace()
#x1B[1m#x1B[31mxarray/namedarray/_array_api/_utils.py#x1B[0m:22: in _maybe_default_namespace
import array_api_compat.numpy as xpd
#x1B[1m#x1B[31mE ModuleNotFoundError: No module named 'array_api_compat'#x1B[0m#x1B[0m
Check warning on line 0 in xarray.tests.test_accessor_dt.TestDatetimeAccessor
github-actions / Test Results
All 9 runs failed: test_total_seconds (xarray.tests.test_accessor_dt.TestDatetimeAccessor)
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
ModuleNotFoundError: No module named 'array_api_compat'
self = <xarray.tests.test_accessor_dt.TestDatetimeAccessor object at 0x12718c7f0>
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/Users/runner/work/xarray/xarray/xarray/tests/test_accessor_dt.py#x1B[0m:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/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/Users/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:671: in __sub__
from xarray.namedarray._array_api import subtract
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:11: in <module>
from xarray.namedarray._array_api._constants import e, inf, nan, newaxis, pi
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_constants.py#x1B[0m:3: in <module>
_xp = _maybe_default_namespace()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
xp = None
def _maybe_default_namespace(xp: ModuleType | None = None) -> ModuleType:
if xp is None:
# import array_api_strict as xpd
> import array_api_compat.numpy as xpd
#x1B[1m#x1B[31mE ModuleNotFoundError: No module named 'array_api_compat'#x1B[0m
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_utils.py#x1B[0m:22: ModuleNotFoundError
Check warning on line 0 in xarray.tests.test_accessor_dt.TestDatetimeAccessor
github-actions / Test Results
All 9 runs failed: test_strftime (xarray.tests.test_accessor_dt.TestDatetimeAccessor)
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
ModuleNotFoundError: No module named 'array_api_compat'
self = <xarray.tests.test_accessor_dt.TestDatetimeAccessor object at 0x12718ee00>
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/Users/runner/work/xarray/xarray/xarray/tests/test_accessor_dt.py#x1B[0m:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:295: in __eq__
return self._binary_op(other, nputils.array_eq)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/nputils.py#x1B[0m:113: in array_eq
return _ensure_bool_is_ndarray(self == other, self, other)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:742: in __eq__
from xarray.namedarray._array_api import equal
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:11: in <module>
from xarray.namedarray._array_api._constants import e, inf, nan, newaxis, pi
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_constants.py#x1B[0m:3: in <module>
_xp = _maybe_default_namespace()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
xp = None
def _maybe_default_namespace(xp: ModuleType | None = None) -> ModuleType:
if xp is None:
# import array_api_strict as xpd
> import array_api_compat.numpy as xpd
#x1B[1m#x1B[31mE ModuleNotFoundError: No module named 'array_api_compat'#x1B[0m
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_utils.py#x1B[0m:22: ModuleNotFoundError
Check warning on line 0 in xarray.tests.test_backends.TestZarrDirectoryStore
github-actions / Test Results
6 out of 9 runs failed: test_write_read_select_write (xarray.tests.test_backends.TestZarrDirectoryStore)
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
artifacts/Test results for macOS-3.12/pytest.xml [took 0s]
Raw output
ModuleNotFoundError: No module named 'array_api_compat'
self = <xarray.tests.test_backends.TestZarrDirectoryStore object at 0x1470c9780>
def test_write_read_select_write(self) -> None:
# Test for https://github.com/pydata/xarray/issues/4084
ds = create_test_data()
# NOTE: using self.roundtrip, which uses open_dataset, will not trigger the bug.
with self.create_zarr_target() as initial_store:
ds.to_zarr(initial_store, mode="w", **self.version_kwargs)
ds1 = xr.open_zarr(initial_store, **self.version_kwargs)
# Combination of where+squeeze triggers error on write.
> ds_sel = ds1.where(ds1.coords["dim3"] == "a", drop=True).squeeze("dim3")
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:3070:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:295: in __eq__
return self._binary_op(other, nputils.array_eq)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/nputils.py#x1B[0m:113: in array_eq
return _ensure_bool_is_ndarray(self == other, self, other)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:742: in __eq__
from xarray.namedarray._array_api import equal
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:11: in <module>
from xarray.namedarray._array_api._constants import e, inf, nan, newaxis, pi
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_constants.py#x1B[0m:3: in <module>
_xp = _maybe_default_namespace()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
xp = None
def _maybe_default_namespace(xp: ModuleType | None = None) -> ModuleType:
if xp is None:
# import array_api_strict as xpd
> import array_api_compat.numpy as xpd
#x1B[1m#x1B[31mE ModuleNotFoundError: No module named 'array_api_compat'#x1B[0m
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_utils.py#x1B[0m:22: ModuleNotFoundError
Check warning on line 0 in xarray.tests.test_backends.TestH5NetCDFData
github-actions / Test Results
8 out of 9 runs failed: test_isel_dataarray (xarray.tests.test_backends.TestH5NetCDFData)
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
ModuleNotFoundError: No module named 'array_api_compat'
self = <xarray.tests.test_backends.TestH5NetCDFData object at 0x12f52a980>
def test_isel_dataarray(self) -> None:
# Make sure isel works lazily. GH:issue:1688
in_memory = create_test_data()
with self.roundtrip(in_memory) as on_disk:
> expected = in_memory.isel(dim2=in_memory["dim2"] < 3)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:800:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/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/Users/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:762: in __lt__
from xarray.namedarray._array_api import less
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:11: in <module>
from xarray.namedarray._array_api._constants import e, inf, nan, newaxis, pi
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_constants.py#x1B[0m:3: in <module>
_xp = _maybe_default_namespace()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
xp = None
def _maybe_default_namespace(xp: ModuleType | None = None) -> ModuleType:
if xp is None:
# import array_api_strict as xpd
> import array_api_compat.numpy as xpd
#x1B[1m#x1B[31mE ModuleNotFoundError: No module named 'array_api_compat'#x1B[0m
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_utils.py#x1B[0m:22: ModuleNotFoundError
Check warning on line 0 in xarray.tests.test_backends.TestZarrWriteEmpty
github-actions / Test Results
6 out of 9 runs failed: test_isel_dataarray (xarray.tests.test_backends.TestZarrWriteEmpty)
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
artifacts/Test results for macOS-3.12/pytest.xml [took 0s]
Raw output
ModuleNotFoundError: No module named 'array_api_compat'
self = <xarray.tests.test_backends.TestZarrWriteEmpty object at 0x14663a740>
def test_isel_dataarray(self) -> None:
# Make sure isel works lazily. GH:issue:1688
in_memory = create_test_data()
with self.roundtrip(in_memory) as on_disk:
> expected = in_memory.isel(dim2=in_memory["dim2"] < 3)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:800:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/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/Users/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:762: in __lt__
from xarray.namedarray._array_api import less
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:11: in <module>
from xarray.namedarray._array_api._constants import e, inf, nan, newaxis, pi
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_constants.py#x1B[0m:3: in <module>
_xp = _maybe_default_namespace()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
xp = None
def _maybe_default_namespace(xp: ModuleType | None = None) -> ModuleType:
if xp is None:
# import array_api_strict as xpd
> import array_api_compat.numpy as xpd
#x1B[1m#x1B[31mE ModuleNotFoundError: No module named 'array_api_compat'#x1B[0m
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_utils.py#x1B[0m:22: ModuleNotFoundError
Check warning on line 0 in xarray.tests.test_backends.TestH5NetCDFData
github-actions / Test Results
8 out of 9 runs failed: test_dropna (xarray.tests.test_backends.TestH5NetCDFData)
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
self = <xarray.tests.test_backends.TestH5NetCDFData object at 0x12f5328f0>
def test_dropna(self) -> None:
# regression test for GH:issue:1694
a = np.random.randn(4, 3)
a[1, 1] = np.nan
in_memory = xr.Dataset(
{"a": (("y", "x"), a)}, coords={"y": np.arange(4), "x": np.arange(3)}
)
assert_identical(
> in_memory.dropna(dim="x"), in_memory.isel(x=slice(None, None, 2))
)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:848:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/util/deprecation_helpers.py#x1B[0m:116: in inner
return func(*args, **kwargs)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:6494: in dropna
count += np.asarray(array.count(dims))
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_aggregations.py#x1B[0m:76: in count
return self.reduce(
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1301: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (y: 4, x: 3)> Size: 96B
array([[ 1.76405235, 0.40015721, 0.97873798],
[ 2.2408932 , nan, -0.97727788],
[ 0.95008842, -0.15135721, -0.10321885],
[ 0.4105985 , 0.14404357, 1.45427351]])
dims = ('y',), 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/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:155: AttributeError
Check warning on line 0 in xarray.tests.test_backends.TestZarrWriteEmpty
github-actions / Test Results
6 out of 9 runs failed: test_dropna (xarray.tests.test_backends.TestZarrWriteEmpty)
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
artifacts/Test results for macOS-3.12/pytest.xml [took 0s]
Raw output
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
self = <xarray.tests.test_backends.TestZarrWriteEmpty object at 0x146636e60>
def test_dropna(self) -> None:
# regression test for GH:issue:1694
a = np.random.randn(4, 3)
a[1, 1] = np.nan
in_memory = xr.Dataset(
{"a": (("y", "x"), a)}, coords={"y": np.arange(4), "x": np.arange(3)}
)
assert_identical(
> in_memory.dropna(dim="x"), in_memory.isel(x=slice(None, None, 2))
)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:848:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/util/deprecation_helpers.py#x1B[0m:116: in inner
return func(*args, **kwargs)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:6494: in dropna
count += np.asarray(array.count(dims))
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_aggregations.py#x1B[0m:76: in count
return self.reduce(
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1301: in reduce
axis_ = _dims_to_axis(self, d, axislike)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = <xarray.Variable (y: 4, x: 3)> Size: 96B
array([[ 1.76405235, 0.40015721, 0.97873798],
[ 2.2408932 , nan, -0.97727788],
[ 0.95008842, -0.15135721, -0.10321885],
[ 0.4105985 , 0.14404357, 1.45427351]])
dims = ('y',), 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/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:155: AttributeError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
All 9 runs failed: test_contains_broadcast[str] (xarray.tests.test_accessor_str)
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
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/Users/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:181:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/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/Users/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/Users/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/Users/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1358: in all
return self.reduce(
#x1B[1m#x1B[31m/Users/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/Users/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1301: 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/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:155: AttributeError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
All 9 runs failed: test_contains_broadcast[bytes] (xarray.tests.test_accessor_str)
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
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/Users/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:181:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/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/Users/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/Users/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/Users/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1358: in all
return self.reduce(
#x1B[1m#x1B[31m/Users/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/Users/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1301: 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/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:155: AttributeError
Check warning on line 0 in xarray.tests.test_backends.TestZarrWriteEmpty
github-actions / Test Results
6 out of 9 runs failed: test_append_overwrite_values (xarray.tests.test_backends.TestZarrWriteEmpty)
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
artifacts/Test results for macOS-3.12/pytest.xml [took 0s]
Raw output
ModuleNotFoundError: No module named 'array_api_compat'
self = <xarray.tests.test_backends.TestZarrWriteEmpty object at 0x14663a350>
def test_append_overwrite_values(self) -> None:
# regression for GH1215
data = create_test_data()
with create_tmp_file(allow_cleanup_failure=False) as tmp_file:
self.save(data, tmp_file, mode="w")
data["var2"][:] = -999
> data["var9"] = data["var2"] * 3
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:1346:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:253: in __mul__
return self._binary_op(other, operator.mul)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:676: in __mul__
from xarray.namedarray._array_api import multiply
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:11: in <module>
from xarray.namedarray._array_api._constants import e, inf, nan, newaxis, pi
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_constants.py#x1B[0m:3: in <module>
_xp = _maybe_default_namespace()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
xp = None
def _maybe_default_namespace(xp: ModuleType | None = None) -> ModuleType:
if xp is None:
# import array_api_strict as xpd
> import array_api_compat.numpy as xpd
#x1B[1m#x1B[31mE ModuleNotFoundError: No module named 'array_api_compat'#x1B[0m
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_utils.py#x1B[0m:22: ModuleNotFoundError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
All 9 runs failed: test_replace_callable (xarray.tests.test_accessor_str)
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
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/Users/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:417:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/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/Users/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/Users/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/Users/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1358: in all
return self.reduce(
#x1B[1m#x1B[31m/Users/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/Users/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1301: 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/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:155: AttributeError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
All 9 runs failed: test_replace_unicode (xarray.tests.test_accessor_str)
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
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/Users/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:442:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/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/Users/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/Users/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/Users/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1358: in all
return self.reduce(
#x1B[1m#x1B[31m/Users/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/Users/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1301: 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/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:155: AttributeError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
All 9 runs failed: test_replace_compiled_regex[str] (xarray.tests.test_accessor_str)
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
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/Users/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:466:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/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/Users/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/Users/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/Users/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1358: in all
return self.reduce(
#x1B[1m#x1B[31m/Users/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/Users/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1301: 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/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:155: AttributeError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
All 9 runs failed: test_replace_compiled_regex[bytes] (xarray.tests.test_accessor_str)
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
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/Users/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:466:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/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/Users/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/Users/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/Users/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1358: in all
return self.reduce(
#x1B[1m#x1B[31m/Users/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/Users/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1301: 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/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:155: AttributeError
Check warning on line 0 in xarray.tests.test_backends.TestH5NetCDFData
github-actions / Test Results
8 out of 9 runs failed: test_append_overwrite_values (xarray.tests.test_backends.TestH5NetCDFData)
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
ModuleNotFoundError: No module named 'array_api_compat'
self = <xarray.tests.test_backends.TestH5NetCDFData object at 0x12f531de0>
def test_append_overwrite_values(self) -> None:
# regression for GH1215
data = create_test_data()
with create_tmp_file(allow_cleanup_failure=False) as tmp_file:
self.save(data, tmp_file, mode="w")
data["var2"][:] = -999
> data["var9"] = data["var2"] * 3
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:1346:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:253: in __mul__
return self._binary_op(other, operator.mul)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:676: in __mul__
from xarray.namedarray._array_api import multiply
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:11: in <module>
from xarray.namedarray._array_api._constants import e, inf, nan, newaxis, pi
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_constants.py#x1B[0m:3: in <module>
_xp = _maybe_default_namespace()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
xp = None
def _maybe_default_namespace(xp: ModuleType | None = None) -> ModuleType:
if xp is None:
# import array_api_strict as xpd
> import array_api_compat.numpy as xpd
#x1B[1m#x1B[31mE ModuleNotFoundError: No module named 'array_api_compat'#x1B[0m
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_utils.py#x1B[0m:22: ModuleNotFoundError
Check warning on line 0 in xarray.tests.test_backends.TestZarrWriteEmpty
github-actions / Test Results
6 out of 9 runs failed: test_write_persistence_modes[None] (xarray.tests.test_backends.TestZarrWriteEmpty)
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
artifacts/Test results for macOS-3.12/pytest.xml [took 0s]
Raw output
NameError: name 'dims' is not defined
self = <xarray.tests.test_backends.TestZarrWriteEmpty object at 0x14510b760>
group = None
@pytest.mark.parametrize("group", [None, "group1"])
def test_write_persistence_modes(self, group) -> None:
original = create_test_data()
# overwrite mode
with self.roundtrip(
original,
save_kwargs={"mode": "w", "group": group},
open_kwargs={"group": group},
) as actual:
assert_identical(original, actual)
# don't overwrite mode
with self.roundtrip(
original,
save_kwargs={"mode": "w-", "group": group},
open_kwargs={"group": group},
) as actual:
assert_identical(original, actual)
# make sure overwriting works as expected
with self.create_zarr_target() as store:
self.save(original, store)
# should overwrite with no error
self.save(original, store, mode="w", group=group)
with self.open(store, group=group) as actual:
assert_identical(original, actual)
with pytest.raises(ValueError):
self.save(original, store, mode="w-")
# check append mode for normal write
with self.roundtrip(
original,
save_kwargs={"mode": "a", "group": group},
open_kwargs={"group": group},
) as actual:
assert_identical(original, actual)
# check append mode for append write
ds, ds_to_append, _ = create_append_test_data()
with self.create_zarr_target() as store_target:
ds.to_zarr(store_target, mode="w", group=group, **self.version_kwargs)
ds_to_append.to_zarr(
store_target, append_dim="time", group=group, **self.version_kwargs
)
> original = xr.concat([ds, ds_to_append], dim="time")
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:2562:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/concat.py#x1B[0m:277: in concat
return _dataset_concat(
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/concat.py#x1B[0m:667: in _dataset_concat
combined_var = concat_vars(
#x1B[1m#x1B[31m/Users/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/Users/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1741: in concat
axis = first_var.get_axis_num(dim)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <xarray.Variable (lat: 3, lon: 3, time: 3)> Size: 216B
array([[[0.27059024, 0.72030174, 0.63106838],
[0.728267... 0.98608612, 0.49313505],
[0.75439345, 0.94027823, 0.00539805],
[0.50539587, 0.48977873, 0.47407012]]])
dim = 'time'
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/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1082: NameError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
All 9 runs failed: test_extract_extractall_findall_empty_raises[str] (xarray.tests.test_accessor_str)
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
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/Users/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:565:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:2236: in extractall
.max()
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1502: in max
return self.reduce(
#x1B[1m#x1B[31m/Users/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/Users/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1301: 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/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:155: AttributeError
Check warning on line 0 in xarray.tests.test_backends.TestH5NetCDFData
github-actions / Test Results
8 out of 9 runs failed: test_append_with_invalid_dim_raises (xarray.tests.test_backends.TestH5NetCDFData)
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
ModuleNotFoundError: No module named 'array_api_compat'
self = <xarray.tests.test_backends.TestH5NetCDFData object at 0x12f532050>
def test_append_with_invalid_dim_raises(self) -> None:
data = create_test_data()
with create_tmp_file(allow_cleanup_failure=False) as tmp_file:
self.save(data, tmp_file, mode="w")
> data["var9"] = data["var2"] * 3
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:1355:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:253: in __mul__
return self._binary_op(other, operator.mul)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataarray.py#x1B[0m:4749: in _binary_op
f(self.variable, other_variable_or_arraylike)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:676: in __mul__
from xarray.namedarray._array_api import multiply
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:11: in <module>
from xarray.namedarray._array_api._constants import e, inf, nan, newaxis, pi
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_constants.py#x1B[0m:3: in <module>
_xp = _maybe_default_namespace()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
xp = None
def _maybe_default_namespace(xp: ModuleType | None = None) -> ModuleType:
if xp is None:
# import array_api_strict as xpd
> import array_api_compat.numpy as xpd
#x1B[1m#x1B[31mE ModuleNotFoundError: No module named 'array_api_compat'#x1B[0m
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_utils.py#x1B[0m:22: ModuleNotFoundError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
All 9 runs failed: test_extract_extractall_findall_empty_raises[bytes] (xarray.tests.test_accessor_str)
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
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/Users/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:565:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:2236: in extractall
.max()
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1502: in max
return self.reduce(
#x1B[1m#x1B[31m/Users/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/Users/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1301: 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/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:155: AttributeError
Check warning on line 0 in xarray.tests.test_backends.TestZarrWriteEmpty
github-actions / Test Results
6 out of 9 runs failed: test_write_persistence_modes[group1] (xarray.tests.test_backends.TestZarrWriteEmpty)
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for macOS-3.10/pytest.xml [took 0s]
artifacts/Test results for macOS-3.12/pytest.xml [took 0s]
Raw output
NameError: name 'dims' is not defined
self = <xarray.tests.test_backends.TestZarrWriteEmpty object at 0x14510b5b0>
group = 'group1'
@pytest.mark.parametrize("group", [None, "group1"])
def test_write_persistence_modes(self, group) -> None:
original = create_test_data()
# overwrite mode
with self.roundtrip(
original,
save_kwargs={"mode": "w", "group": group},
open_kwargs={"group": group},
) as actual:
assert_identical(original, actual)
# don't overwrite mode
with self.roundtrip(
original,
save_kwargs={"mode": "w-", "group": group},
open_kwargs={"group": group},
) as actual:
assert_identical(original, actual)
# make sure overwriting works as expected
with self.create_zarr_target() as store:
self.save(original, store)
# should overwrite with no error
self.save(original, store, mode="w", group=group)
with self.open(store, group=group) as actual:
assert_identical(original, actual)
with pytest.raises(ValueError):
self.save(original, store, mode="w-")
# check append mode for normal write
with self.roundtrip(
original,
save_kwargs={"mode": "a", "group": group},
open_kwargs={"group": group},
) as actual:
assert_identical(original, actual)
# check append mode for append write
ds, ds_to_append, _ = create_append_test_data()
with self.create_zarr_target() as store_target:
ds.to_zarr(store_target, mode="w", group=group, **self.version_kwargs)
ds_to_append.to_zarr(
store_target, append_dim="time", group=group, **self.version_kwargs
)
> original = xr.concat([ds, ds_to_append], dim="time")
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:2562:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/concat.py#x1B[0m:277: in concat
return _dataset_concat(
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/concat.py#x1B[0m:667: in _dataset_concat
combined_var = concat_vars(
#x1B[1m#x1B[31m/Users/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/Users/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1741: in concat
axis = first_var.get_axis_num(dim)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <xarray.Variable (lat: 3, lon: 3, time: 3)> Size: 216B
array([[[0.22191874, 0.89823848, 0.19997297],
[0.901056... 0.11934181, 0.34869584],
[0.22087265, 0.60153981, 0.42224052],
[0.82268364, 0.91110839, 0.06194036]]])
dim = 'time'
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/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1082: NameError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
All 9 runs failed: test_extract_broadcast[str] (xarray.tests.test_accessor_str)
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
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/Users/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:862:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:2052: in extract
.max()
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1502: in max
return self.reduce(
#x1B[1m#x1B[31m/Users/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/Users/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1301: 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/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:155: AttributeError
Check warning on line 0 in xarray.tests.test_backends.TestH5NetCDFData
github-actions / Test Results
8 out of 9 runs failed: test_write_groups (xarray.tests.test_backends.TestH5NetCDFData)
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
ModuleNotFoundError: No module named 'array_api_compat'
self = <xarray.tests.test_backends.TestH5NetCDFData object at 0x12f5bf790>
def test_write_groups(self) -> None:
data1 = create_test_data()
> data2 = data1 * 2
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/tests/test_backends.py#x1B[0m:1493:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_typed_ops.py#x1B[0m:41: in __mul__
return self._binary_op(other, operator.mul)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7777: in _binary_op
ds = self._calculate_binary_op(g, other, join=align_type)
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7846: in _calculate_binary_op
new_vars = {k: f(self.variables[k], other_variable) for k in self.data_vars}
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/dataset.py#x1B[0m:7846: in <dictcomp>
new_vars = {k: f(self.variables[k], other_variable) for k in self.data_vars}
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:676: in __mul__
from xarray.namedarray._array_api import multiply
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/__init__.py#x1B[0m:11: in <module>
from xarray.namedarray._array_api._constants import e, inf, nan, newaxis, pi
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_constants.py#x1B[0m:3: in <module>
_xp = _maybe_default_namespace()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
xp = None
def _maybe_default_namespace(xp: ModuleType | None = None) -> ModuleType:
if xp is None:
# import array_api_strict as xpd
> import array_api_compat.numpy as xpd
#x1B[1m#x1B[31mE ModuleNotFoundError: No module named 'array_api_compat'#x1B[0m
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/_array_api/_utils.py#x1B[0m:22: ModuleNotFoundError
Check warning on line 0 in xarray.tests.test_accessor_str
github-actions / Test Results
All 9 runs failed: test_extract_broadcast[bytes] (xarray.tests.test_accessor_str)
artifacts/Test results for Linux-3.10 bare-minimum/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10 min-all-deps/pytest.xml [took 0s]
artifacts/Test results for Linux-3.10/pytest.xml [took 0s]
artifacts/Test results for Linux-3.11 all-but-dask/pytest.xml [took 0s]
artifacts/Test results for Linux-3.12/pytest.xml [took 0s]
artifacts/Test results for Windows-3.10/pytest.xml [took 0s]
artifacts/Test results for Windows-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
AttributeError: 'Variable' object has no attribute '_dims_to_axes'. Did you mean: '_dim_to_axis'?
dtype = <class 'numpy.bytes_'>
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/Users/runner/work/xarray/xarray/xarray/tests/test_accessor_str.py#x1B[0m:862:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/accessor_str.py#x1B[0m:2052: in extract
.max()
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/core/_aggregations.py#x1B[0m:1502: in max
return self.reduce(
#x1B[1m#x1B[31m/Users/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/Users/runner/work/xarray/xarray/xarray/core/variable.py#x1B[0m:1668: in reduce
result = super().reduce(
#x1B[1m#x1B[31m/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:1301: 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/Users/runner/work/xarray/xarray/xarray/namedarray/core.py#x1B[0m:155: AttributeError