You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromsympyimport*i=symbols('i', integer=True)
α=symbols('α', real=True)
x=symbols('x', real=True, positive=True)
c=symbols('c', real=True)
f=c*pow(x, i+α)
expr=simplify(collect(diff(f, x), x))
print(latex(expr)) # works as expectedco=expr.coeff(x, i+α-1)
Visual inspection of the print allows us to easily determine the result should be (i+α)c, but instead we get:
Traceback (most recent call last):
File "~/lib/python3.12/site-packages/sympy/utilities/misc.py", line 555, in as_int
return operator.index(n)
^^^^^^^^^^^^^^^^^
TypeError: 'Add' object cannot be interpreted as an integer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "reproduce.py", line 9, in <module>
co = expr.coeff(x, i + α - 1)
^^^^^^^^^^^^^^^^^^^^^^^^
File "~/lib/python3.12/site-packages/sympy/core/expr.py", line 1461, in coeff
n = as_int(n)
^^^^^^^^^
File "~/lib/python3.12/site-packages/sympy/utilities/misc.py", line 557, in as_int
raise ValueError('%s is not an integer' % (n,))
ValueError: i + α - 1 is not an integer
Now, I concede that this is probably just a feature request, but nonetheless I figured I'd see if someone put the assert in there just for safety, even though real-valued arguments should work just fine.
Other information:
$ pip show sympy
Version: 1.12
The text was updated successfully, but these errors were encountered:
To reproduce:
Visual inspection of the print allows us to easily determine the result should be (i+α)c, but instead we get:
Now, I concede that this is probably just a feature request, but nonetheless I figured I'd see if someone put the assert in there just for safety, even though real-valued arguments should work just fine.
Other information:
The text was updated successfully, but these errors were encountered: