Skip to content

Commit

Permalink
Merge pull request #21928 from oscargus/fix21651
Browse files Browse the repository at this point in the history
Fixed issue with determining is_integer for round functions (#21651)
  • Loading branch information
smichr committed Aug 24, 2021
2 parents 6fdba11 + a88f701 commit 63b8665
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
7 changes: 7 additions & 0 deletions sympy/concrete/tests/test_sums_products.py
Expand Up @@ -1429,6 +1429,13 @@ def test_matrixsymbol_summation_numerical_limits():
assert Sum(A**n*B**n, (n, 1, 3)).doit() == ans


def test_issue_21651():
from sympy import floor, Sum, Symbol
i = Symbol('i')
a = Sum(floor(2*2**(-i)), (i, S.One, 2))
assert a.doit() == S.One


@XFAIL
def test_matrixsymbol_summation_symbolic_limits():
N = Symbol('N', integer=True, positive=True)
Expand Down
2 changes: 1 addition & 1 deletion sympy/core/mul.py
Expand Up @@ -1351,7 +1351,7 @@ def _eval_is_integer(self):
b, e = a.as_base_exp()
if not b.is_integer or not e.is_integer: return
if e.is_negative:
denominators.append(b)
denominators.append(2 if a is S.Half else Pow(a, S.NegativeOne))
else:
# for integer b and positive integer e: a = b**e would be integer
assert not e.is_positive
Expand Down
6 changes: 6 additions & 0 deletions sympy/core/tests/test_assumptions.py
Expand Up @@ -1198,6 +1198,12 @@ def test_issue_17556():
assert z.is_finite is False


def test_issue_21651():
k = Symbol('k', positive=True, integer=True)
exp = 2*2**(-k)
assert exp.is_integer is None


def test_assumptions_copy():
assert assumptions(Symbol('x'), dict(commutative=True)
) == {'commutative': True}
Expand Down
6 changes: 6 additions & 0 deletions sympy/functions/elementary/tests/test_integers.py
Expand Up @@ -548,6 +548,12 @@ def test_issue_4149():
assert floor(3 + E + pi*I + y*I) == 5 + floor(pi + y)*I


def test_issue_21651():
k = Symbol('k', positive=True, integer=True)
exp = 2*2**(-k)
assert isinstance(floor(exp), floor)


def test_issue_11207():
assert floor(floor(x)) == floor(x)
assert floor(ceiling(x)) == ceiling(x)
Expand Down

0 comments on commit 63b8665

Please sign in to comment.