Skip to content

Commit

Permalink
bitwise operators
Browse files Browse the repository at this point in the history
  • Loading branch information
Illviljan committed Aug 18, 2024
1 parent 17eed31 commit a147c64
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions xarray/namedarray/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,38 @@ def __matmul__(self, other, /):

return matmul(self, other)

# Bitwise Operators

def __invert__(self, /):
from xarray.namedarray._array_api import bitwise_invert

return bitwise_invert(self)

def __and__(self, other, /):
from xarray.namedarray._array_api import bitwise_and

return bitwise_and(self)

def __or__(self, other, /):
from xarray.namedarray._array_api import bitwise_or

return bitwise_or(self)

def __xor__(self, other, /):
from xarray.namedarray._array_api import bitwise_xor

return bitwise_xor(self)

def __lshift__(self, other, /):
from xarray.namedarray._array_api import bitwise_left_shift

return bitwise_left_shift(self)

def __rshift__(self, other, /):
from xarray.namedarray._array_api import bitwise_right_shift

return bitwise_right_shift(self)

# Comparison Operators

def __eq__(self, other, /):
Expand Down

0 comments on commit a147c64

Please sign in to comment.