Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid a couple of warnings in polyfit #8939

Merged
merged 15 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,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"
Expand Down
6 changes: 2 additions & 4 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,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 "
Expand Down Expand Up @@ -8922,9 +8922,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 # type: ignore[attr-defined]
dcherian marked this conversation as resolved.
Show resolved Hide resolved

# Weights:
if w is not None:
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/datatree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__()

Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down
Loading