8000 add return_scalar=False as __array_wrap__ kwarg by gcaria · Pull Request #10264 · pydata/xarray · GitHub
[go: up one dir, main page]

Skip to content

add return_scalar=False as __array_wrap__ kwarg #10264

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

Merged
merged 5 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 3 additions & 11 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@
from functools import partial
from os import PathLike
from types import EllipsisType
from typing import (
TYPE_CHECKING,
Any,
Generic,
Literal,
NoReturn,
TypeVar,
overload,
)
from typing import TYPE_CHECKING, Any, Generic, Literal, NoReturn, TypeVar, overload

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -4812,8 +4804,8 @@ def identical(self, other: Self) -> bool:
except (TypeError, AttributeError):
return False

def __array_wrap__(self, obj, context=None) -> Self:
new_var = self.variable.__array_wrap__(obj, context)
def __array_wrap__(self, obj, context=None, return_scalar=False) -> Self:
new_var = self.variable.__array_wrap__(obj, context, return_scalar)
return self._replace(new_var)

def __matmul__(self, obj: T_Xarray) -> T_Xarray:
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -2304,7 +2304,7 @@ def real(self) -> Variable:
"""
return self._new(data=self.data.real)

def __array_wrap__(self, obj, context=None):
def __array_wrap__(self, obj, context=None, return_scalar=False):
return Variable(self.dims, obj)

def _unary_op(self, f, *args, **kwargs):
Expand Down
Loading
0