Skip to content

Commit

Permalink
concrete: stop doit() in _eval_factor() helper
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Dec 7, 2022
1 parent 1257229 commit 08dfb0a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion diofant/concrete/expr_with_limits.py
Expand Up @@ -407,7 +407,9 @@ def _eval_factor(self, **hints):
else:
summand = self.func(self.function, self.limits[0:-1]).factor()
if not summand.has(self.variables[-1]):
return self.func(1, [self.limits[-1]]).doit()*summand
return self.func(1, [self.limits[-1]])*summand
elif isinstance(summand, Mul):
return self.func(summand, self.limits[-1]).factor()
return self

def _eval_expand_basic(self, **hints):
Expand Down
7 changes: 7 additions & 0 deletions diofant/tests/polys/test_polytools.py
Expand Up @@ -2365,6 +2365,13 @@ def test_factor():
assert (2*Sum(3*x, (x, 1, 9))).factor() == 6*Sum(x, (x, 1, 9))
assert (2*Sum(x**2, (x, 1, 9))).factor() == 2*Sum(x**2, (x, 1, 9))

# issue sympy/sympy#24346
i = Integral(2*x, x, y)
assert factor(i) == 2*Integral(x, x)*Integral(1, y)
assert factor(1 + i) == 1 + i
i2 = Integral(2*x*y, x, y)
assert factor(i2) == 2*Integral(x, x)*Integral(y, y)

A, B = symbols('A B', commutative=False)
f = (x - A)*(y - B)
assert factor(f.expand()) == f
Expand Down
1 change: 1 addition & 0 deletions docs/release/notes-0.14.rst
Expand Up @@ -103,3 +103,4 @@ These Sympy issues also were addressed:
* :sympyissue:`24210`: Error on limits regarding terms like (1+u)^v.
* :sympyissue:`24225`: Multivariable limit should be undefined, but gives unity.
* :sympyissue:`24266`: Changed behaviour of series() involving exp, I
* :sympyissue:`24346`: factor with extension=True fails for rational expression

0 comments on commit 08dfb0a

Please sign in to comment.