Skip to content

Commit

Permalink
REF replace impossible cases by corresponding assertions
Browse files Browse the repository at this point in the history
(cherry picked from commit de4cc96)
  • Loading branch information
coproc authored and tbennun committed Nov 18, 2020
1 parent 47c5cf7 commit 73f3d75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sympy/core/mul.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,12 +1284,12 @@ def _eval_is_integer(self):
if not b.is_integer or not e.is_integer: return
if e.is_negative:
denominators.append(b)
elif e.is_positive:
denominators.append(b)
elif e.is_zero:
if b.is_zero: return
else:
return
# for integer b and positive integer e: a = b**e would be integer
assert not e.is_positive
# for self being rational and e equal to zero: a = b**e would be 1
assert not e.is_zero
return # sign of e unknown -> self.is_integer cannot be decided
else:
return

Expand Down
2 changes: 2 additions & 0 deletions sympy/core/tests/test_arit.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ def test_Mul_is_integer():
assert (x*k*n).is_integer is None
assert (e/2).is_integer is True
assert (e**2/2).is_integer is True
assert (2/k).is_integer is None
assert (2/k**2).is_integer is None
assert ((-1)**k*n).is_integer is True
assert (3*k*e/2).is_integer is True
assert (2*k*e/3).is_integer is None
Expand Down

0 comments on commit 73f3d75

Please sign in to comment.