Skip to content

Commit

Permalink
Update core.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Illviljan committed Aug 22, 2024
1 parent 3833e04 commit 71d4876
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions xarray/namedarray/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,8 @@ def __xor__(self, other: int | bool | NamedArray, /):
return bitwise_xor(self)

def __iadd__(self, other: int | float | NamedArray, /):
from xarray.namedarray._array_api import asarray

self._data.__iadd__(asarray(other)._data)
return self

Expand All @@ -611,6 +613,8 @@ def __radd__(self, other: int | float | NamedArray, /):
return add(asarray(other), self)

def __iand__(self, other: int | bool | NamedArray, /):
from xarray.namedarray._array_api import asarray

self._data.__iand__(asarray(other)._data)
return self

Expand All @@ -620,6 +624,8 @@ def __rand__(self, other: int | bool | NamedArray, /):
return bitwise_and(asarray(other), self)

def __ifloordiv__(self, other: int | float | NamedArray, /):
from xarray.namedarray._array_api import asarray

self._data.__ifloordiv__(asarray(other)._data)
return self

Expand All @@ -629,6 +635,8 @@ def __rfloordiv__(self, other: int | float | NamedArray, /):
return floor_divide(asarray(other), self)

def __ilshift__(self, other: int | NamedArray, /):
from xarray.namedarray._array_api import asarray

self._data.__ilshift__(asarray(other)._data)
return self

Expand All @@ -647,6 +655,8 @@ def __rmatmul__(self, other: NamedArray, /):
return matmul(asarray(other), self)

def __imod__(self, other: int | float | NamedArray, /):
from xarray.namedarray._array_api import asarray

self._data.__imod__(asarray(other)._data)
return self

Expand All @@ -656,6 +666,8 @@ def __rmod__(self, other: int | float | NamedArray, /):
return remainder(asarray(other), self)

def __imul__(self, other: int | float | NamedArray, /):
from xarray.namedarray._array_api import asarray

self._data.__imul__(asarray(other)._data)
return self

Expand All @@ -665,6 +677,8 @@ def __rmul__(self, other: int | float | NamedArray, /):
return multiply(asarray(other), self)

def __ior__(self, other: int | bool | NamedArray, /):
from xarray.namedarray._array_api import asarray

self._data.__ior__(asarray(other)._data)
return self

Expand All @@ -674,6 +688,8 @@ def __ror__(self, other: int | bool | NamedArray, /):
return bitwise_or(asarray(other), self)

def __ipow__(self, other: int | float | NamedArray, /):
from xarray.namedarray._array_api import asarray

self._data.__ipow__(asarray(other)._data)
return self

Expand All @@ -683,6 +699,8 @@ def __rpow__(self, other: int | float | NamedArray, /):
return pow(asarray(other), self)

def __irshift__(self, other: int | NamedArray, /):
from xarray.namedarray._array_api import asarray

self._data.__irshift__(asarray(other)._data)
return self

Expand All @@ -692,6 +710,8 @@ def __rrshift__(self, other: int | NamedArray, /):
return bitwise_right_shift(asarray(other), self)

def __isub__(self, other: int | float | NamedArray, /):
from xarray.namedarray._array_api import asarray

self._data.__isub__(asarray(other)._data)
return self

Expand All @@ -701,6 +721,8 @@ def __rsub__(self, other: int | float | NamedArray, /):
return subtract(asarray(other), self)

def __itruediv__(self, other: float | NamedArray, /):
from xarray.namedarray._array_api import asarray

self._data.__itruediv__(asarray(other)._data)
return self

Expand All @@ -710,6 +732,8 @@ def __rtruediv__(self, other: float | NamedArray, /):
return divide(asarray(other), self)

def __ixor__(self, other: int | bool | NamedArray, /):
from xarray.namedarray._array_api import asarray

self._data.__ixor__(asarray(other)._data)
return self

Expand Down

0 comments on commit 71d4876

Please sign in to comment.