Skip to content

Commit

Permalink
Disallow unsupported numpy functions
Browse files Browse the repository at this point in the history
  • Loading branch information
amirebrahimi committed Dec 14, 2024
1 parent 7054295 commit b9d75e0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/galois/_fields/_gf2.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class subtract_ufunc_bitpacked(subtract_ufunc):

def __call__(self, ufunc, method, inputs, kwargs, meta):
output = super().__call__(ufunc, method, inputs, kwargs, meta)
output._axis_count = inputs[0]._axis_count
output._axis_count = max(i._axis_count for i in inputs)
return output


Expand All @@ -158,7 +158,7 @@ class multiply_ufunc_bitpacked(multiply_ufunc):

def __call__(self, ufunc, method, inputs, kwargs, meta):
output = super().__call__(ufunc, method, inputs, kwargs, meta)
output._axis_count = inputs[0]._axis_count
output._axis_count = max(i._axis_count for i in inputs)
return output


Expand All @@ -169,7 +169,7 @@ class divide_ufunc_bitpacked(divide):

def __call__(self, ufunc, method, inputs, kwargs, meta):
output = super().__call__(ufunc, method, inputs, kwargs, meta)
output._axis_count = inputs[0]._axis_count
output._axis_count = max(i._axis_count for i in inputs)
return output


Expand Down Expand Up @@ -218,6 +218,7 @@ def __call__(self, ufunc, method, inputs, kwargs, meta):


def not_implemented(*args, **kwargs):
# TODO: Add a better error message about limited support
return NotImplemented

class UFuncMixin_2_1_BitPacked(UFuncMixin):
Expand All @@ -231,10 +232,10 @@ def __init_subclass__(cls) -> None:
cls._negative = negative_ufunc(cls, override=np.positive)
cls._subtract = subtract_ufunc_bitpacked(cls, override=np.bitwise_xor)
cls._multiply = multiply_ufunc_bitpacked(cls, override=np.bitwise_and)
cls._reciprocal = reciprocal(cls)
cls._reciprocal = not_implemented # reciprocal(cls)
cls._divide = divide_ufunc_bitpacked(cls)
cls._power = power(cls)
cls._log = log(cls)
cls._power = not_implemented # power(cls)
cls._log = not_implemented # log(cls)
cls._sqrt = sqrt(cls)
cls._packbits = packbits
cls._unpackbits = unpackbits
Expand Down

0 comments on commit b9d75e0

Please sign in to comment.