mirror of https://github.com/Nonannet/copapy.git
python pow function fixed and changed to musl implementation
This commit is contained in:
parent
5b77ce236f
commit
ee4d22265c
|
|
@ -243,7 +243,7 @@ class variable(Generic[TNum], Net):
|
|||
@overload
|
||||
def __rpow__(self, other: float) -> 'variable[float]': ...
|
||||
def __rpow__(self, other: NumLike) -> Any:
|
||||
return add_op('rpow', [other, self])
|
||||
return cp.pow(other, self)
|
||||
|
||||
def __hash__(self) -> int:
|
||||
return super().__hash__()
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ def pow(x: NumLike, y: NumLike) -> NumLike:
|
|||
Returns:
|
||||
result of x**y
|
||||
"""
|
||||
if isinstance(y, int) and 0 <= y < 16:
|
||||
if isinstance(y, int) and 0 <= y < 8:
|
||||
if y == 0:
|
||||
return 1
|
||||
m = x
|
||||
|
|
@ -66,7 +66,10 @@ def pow(x: NumLike, y: NumLike) -> NumLike:
|
|||
return m
|
||||
if y == -1:
|
||||
return 1 / x
|
||||
return exp(y * log(x))
|
||||
if isinstance(x, variable) or isinstance(y, variable):
|
||||
return add_op('pow', [x, y])
|
||||
else:
|
||||
return float(x ** y)
|
||||
|
||||
|
||||
@overload
|
||||
|
|
|
|||
Loading…
Reference in New Issue