Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 2060 by [email protected]: Infinite recursion on collect
http://code.google.com/p/sympy/issues/detail?id=2060
On Python 2.6.5, running the following example script produces an infinite
recursion:
# begin code
from sympy import *
from sympy.tensor import Indexed, Idx, IndexedElement
M = Indexed('M')
var('A B C D E')
i,j,n = symbols('i j n', integer = True)
i = 1
j = 1
expr = Eq( A*M(i,j)**n + B*M(i+1,j)**(n+1),
C*M(i,j+1)**n + D*M(i,j)**(n+1) +
E*M(i+1,j)**(n+1) )
expr1 = expr.lhs - expr.rhs
u = Symbol('u', dummy=True)
IE_atoms = expr1.atoms(IndexedElement)
print collect(expr1.subs([(a**(n+1), u*a**(n+1)) for a in IE_atoms]), u) #
begin code
# end code
The very long traceback is as follows:
File "/usr/local/lib/python2.6/dist-packages/sympy/core/mul.py", line 904,
in _eval_subs
Mul(*expr)._eval_subs(old,new))
File "/usr/local/lib/python2.6/dist-packages/sympy/core/mul.py", line
904, in _eval_subs
[snip lines of repeated error]
File "/usr/local/lib/python2.6/dist-packages/sympy/core/mul.py", line
904, in _eval_subs
Mul(*expr)._eval_subs(old,new))
File "/usr/local/lib/python2.6/dist-packages/sympy/core/cache.py", line
85, in wrapper
func_cache_it_cache[k] = r = func(*args, **kw_args)
File "/usr/local/lib/python2.6/dist-packages/sympy/core/operations.py",
line 35, in __new__
c_part, nc_part, order_symbols = cls.flatten(map(_sympify, args))
File "/usr/local/lib/python2.6/dist-packages/sympy/core/mul.py", line
229, in flatten
c_part.append(Pow(b, e))
File "/usr/local/lib/python2.6/dist-packages/sympy/core/cache.py", line
82, in wrapper
return func_cache_it_cache[k]
File "/usr/local/lib/python2.6/dist-packages/sympy/core/numbers.py", line
956, in __hash__
return super(Integer, self).__hash__()
File "/usr/local/lib/python2.6/dist-packages/sympy/core/numbers.py", line
730, in __hash__
return super(Rational, self).__hash__()
File "/usr/local/lib/python2.6/dist-packages/sympy/core/numbers.py", line
220, in __hash__
return super(Number, self).__hash__()
File "/usr/local/lib/python2.6/dist-packages/sympy/core/basic.py", line
192, in __hash__
h = (type(self).__name__,) + self._hashable_content()
RuntimeError: maximum recursion depth exceeded while calling a Python object
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.