Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
math exponentiation now works as expected for inf
Browse files Browse the repository at this point in the history
  • Loading branch information
rjdbcm committed Nov 22, 2021
1 parent 99fc114 commit f5db962
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 0 additions & 4 deletions Aspidites/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,6 @@ def SafeMod(a: Numeric, b: Numeric) -> Union[Numeric, Undefined]:

# noinspection PyPep8Naming, PyProtectedMember,PyUnresolvedReferences
def SafeExp(a: Numeric, b: Numeric) -> Union[Numeric, Undefined]:
if (
(a == 0 and b == 0) or (isinf(a) and b == 0) or (isinf(b) and a == 0)
): # pragma: no cover
return Undefined(SafeExp, a, b)
try:
return a ** b
except OverflowError:
Expand Down
6 changes: 3 additions & 3 deletions Aspidites/tests/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ def test_safe_div(x, y):
@hypothesis.settings(deadline=None)
@pt.mark.filterwarnings("ignore::RuntimeWarning")
def test_safe_exp(x, y):
assert SafeExp(0, 0) == Undefined()
assert SafeExp(0, inf) == Undefined()
assert SafeExp(inf, 0) == Undefined()
assert SafeExp(0, 0) == 1
assert SafeExp(0, inf) == 0.0
assert SafeExp(inf, 0) == 1.0
assume(x != 0 and y != 0)
try:
x ** y
Expand Down

0 comments on commit f5db962

Please sign in to comment.