diff --git a/pyproject.toml b/pyproject.toml index 96147221401..db64d7a18c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -330,6 +330,8 @@ filterwarnings = [ "default:Using a non-tuple sequence for multidimensional indexing is deprecated:FutureWarning", "default:Duplicate dimension names present:UserWarning:xarray.namedarray.core", "default:::xarray.tests.test_strategies", + # TODO: remove once we know how to deal with a changed signature in protocols + "ignore:__array__ implementation doesn't accept a copy keyword, so passing copy=False failed.", ] log_cli_level = "INFO" diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 57ddcd9d39d..747b26ce6e9 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -1524,7 +1524,7 @@ def __iter__(self) -> Iterator[Hashable]: else: - def __array__(self, dtype=None): + def __array__(self, dtype=None, copy=None): raise TypeError( "cannot directly convert an xarray.Dataset into a " "numpy array. Instead, create an xarray.DataArray " @@ -8937,9 +8937,7 @@ def polyfit( lhs = np.vander(x, order) if rcond is None: - rcond = ( - x.shape[0] * np.core.finfo(x.dtype).eps # type: ignore[attr-defined] - ) + rcond = x.shape[0] * np.finfo(x.dtype).eps # Weights: if w is not None: diff --git a/xarray/core/datatree.py b/xarray/core/datatree.py index 48c714b697c..9c4462e3aff 100644 --- a/xarray/core/datatree.py +++ b/xarray/core/datatree.py @@ -624,7 +624,7 @@ def __bool__(self) -> bool: def __iter__(self) -> Iterator[Hashable]: return itertools.chain(self.ds.data_vars, self.children) - def __array__(self, dtype=None): + def __array__(self, dtype=None, copy=None): raise TypeError( "cannot directly convert a DataTree into a " "numpy array. Instead, create an xarray.DataArray " diff --git a/xarray/tests/test_assertions.py b/xarray/tests/test_assertions.py index 59861ef7981..f7e49a0f3de 100644 --- a/xarray/tests/test_assertions.py +++ b/xarray/tests/test_assertions.py @@ -149,7 +149,7 @@ def dims(self): warnings.warn("warning in test") return super().dims - def __array__(self): + def __array__(self, dtype=None, copy=None): warnings.warn("warning in test") return super().__array__() diff --git a/xarray/tests/test_formatting.py b/xarray/tests/test_formatting.py index cb765ce91f8..2c40ac88f98 100644 --- a/xarray/tests/test_formatting.py +++ b/xarray/tests/test_formatting.py @@ -877,7 +877,7 @@ def test_lazy_array_wont_compute() -> None: from xarray.core.indexing import LazilyIndexedArray class LazilyIndexedArrayNotComputable(LazilyIndexedArray): - def __array__(self, dtype=None): + def __array__(self, dtype=None, copy=None): raise NotImplementedError("Computing this array is not possible.") arr = LazilyIndexedArrayNotComputable(np.array([1, 2]))