Skip to content

Commit 5101a52

Browse files
gcariaGiacomo Cariapre-commit-ci[bot]
authored
add return_scalar=False as __array_wrap__ kwarg (pydata#10264)
Co-authored-by: Giacomo Caria <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent d7a6f2b commit 5101a52

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

xarray/core/dataarray.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,7 @@
1414
from functools import partial
1515
from os import PathLike
1616
from types import EllipsisType
17-
from typing import (
18-
TYPE_CHECKING,
19-
Any,
20-
Generic,
21-
Literal,
22-
NoReturn,
23-
TypeVar,
24-
overload,
25-
)
17+
from typing import TYPE_CHECKING, Any, Generic, Literal, NoReturn, TypeVar, overload
2618

2719
import numpy as np
2820
import pandas as pd
@@ -4812,8 +4804,8 @@ def identical(self, other: Self) -> bool:
48124804
except (TypeError, AttributeError):
48134805
return False
48144806

4815-
def __array_wrap__(self, obj, context=None) -> Self:
4816-
new_var = self.variable.__array_wrap__(obj, context)
4807+
def __array_wrap__(self, obj, context=None, return_scalar=False) -> Self:
4808+
new_var = self.variable.__array_wrap__(obj, context, return_scalar)
48174809
return self._replace(new_var)
48184810

48194811
def __matmul__(self, obj: T_Xarray) -> T_Xarray:

xarray/core/variable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2304,7 +2304,7 @@ def real(self) -> Variable:
23042304
"""
23052305
return self._new(data=self.data.real)
23062306

2307-
def __array_wrap__(self, obj, context=None):
2307+
def __array_wrap__(self, obj, context=None, return_scalar=False):
23082308
return Variable(self.dims, obj)
23092309

23102310
def _unary_op(self, f, *args, **kwargs):

0 commit comments

Comments
 (0)