Error in __sympifyit_wrapper when entering fractions
Closed this issue · 5 comments
In the latest live shell backed by SymPy 1.5.1, trying to input a fraction expression like
>>> 1/x
results in an error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/base/data/home/apps/s~sympy-live-hrd/20200105t193609.423659059328302322/sympy/sympy/core/decorators.py", line 91, in __sympifyit_wrapper
return func(a, b)
File "/base/data/home/apps/s~sympy-live-hrd/20200105t193609.423659059328302322/sympy/sympy/core/numbers.py", line 1765, in __div__
return Number.__div__(self, other)
File "/base/data/home/apps/s~sympy-live-hrd/20200105t193609.423659059328302322/sympy/sympy/core/decorators.py", line 91, in __sympifyit_wrapper
return func(a, b)
File "/base/data/home/apps/s~sympy-live-hrd/20200105t193609.423659059328302322/sympy/sympy/core/numbers.py", line 766, in __div__
return AtomicExpr.__div__(self, other)
File "/base/data/home/apps/s~sympy-live-hrd/20200105t193609.423659059328302322/sympy/sympy/core/decorators.py", line 91, in __sympifyit_wrapper
return func(a, b)
File "/base/data/home/apps/s~sympy-live-hrd/20200105t193609.423659059328302322/sympy/sympy/core/decorators.py", line 129, in binary_op_wrapper
return func(self, other)
File "/base/data/home/apps/s~sympy-live-hrd/20200105t193609.423659059328302322/sympy/sympy/core/expr.py", line 233, in __div__
return Mul(self, Pow(other, S.NegativeOne))
File "/base/data/home/apps/s~sympy-live-hrd/20200105t193609.423659059328302322/sympy/sympy/core/cache.py", line 94, in wrapper
retval = cfunc(*args, **kwargs)
File "/base/data/home/apps/s~sympy-live-hrd/20200105t193609.423659059328302322/sympy/sympy/core/compatibility.py", line 916, in wrapper
del cache[oldkey]
KeyError: [<class 'sympy.core.mul.Mul'>, 1, 1/x, <class 'sympy.core.assumptions.ManagedProperties'>, <class 'sympy.core.numbers.One'>, <class 'sympy.core.power.Pow'>]
Works fine in local installation. Normally I would suspect, int_to_Integer
but some basic local testing failed to reproduce.
Not sure when __sympifyit_wrapper
gets called in the web shell.
This commit might be relevant this commit since it touches __sympifyit
, but not sure if it has landed in 1.5.1: sympy/sympy@da1d85b
Something definitely broke. I tried re-running short snippets that used to work fine but now they blow up. I wasn't able to reproduce the bug using 1/x
(with the default x
) but I did encounter it when defining a new variable for myself. Looks something like this:
>>> x1 = symbols('x1')
>>> 1/x1
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/base/data/home/apps/s~sympy-live-hrd/20200105t193609.423659059328302322/sympy/sympy/core/decorators.py", line 91, in __sympifyit_wrapper
return func(a, b)
File "/base/data/home/apps/s~sympy-live-hrd/20200105t193609.423659059328302322/sympy/sympy/core/numbers.py", line 1765, in __div__
return Number.__div__(self, other)
File "/base/data/home/apps/s~sympy-live-hrd/20200105t193609.423659059328302322/sympy/sympy/core/decorators.py", line 91, in __sympifyit_wrapper
return func(a, b)
File "/base/data/home/apps/s~sympy-live-hrd/20200105t193609.423659059328302322/sympy/sympy/core/numbers.py", line 766, in __div__
return AtomicExpr.__div__(self, other)
File "/base/data/home/apps/s~sympy-live-hrd/20200105t193609.423659059328302322/sympy/sympy/core/decorators.py", line 91, in __sympifyit_wrapper
return func(a, b)
File "/base/data/home/apps/s~sympy-live-hrd/20200105t193609.423659059328302322/sympy/sympy/core/decorators.py", line 129, in binary_op_wrapper
return func(self, other)
File "/base/data/home/apps/s~sympy-live-hrd/20200105t193609.423659059328302322/sympy/sympy/core/expr.py", line 233, in __div__
return Mul(self, Pow(other, S.NegativeOne))
File "/base/data/home/apps/s~sympy-live-hrd/20200105t193609.423659059328302322/sympy/sympy/core/cache.py", line 94, in wrapper
retval = cfunc(*args, **kwargs)
File "/base/data/home/apps/s~sympy-live-hrd/20200105t193609.423659059328302322/sympy/sympy/core/compatibility.py", line 916, in wrapper
del cache[oldkey]
KeyError: [<class 'sympy.core.power.Pow'>, x1, -1, <class 'sympy.core.assumptions.ManagedProperties'>, <class 'sympy.core.symbol.Symbol'>, <class 'sympy.core.numbers.NegativeOne'>]
Weirder still, it seems intermittent. Just now I tried again and it didn't happen. Perhaps there's something wrong with a specific node/instance of the web application?
This commit might be relevant this commit since it touches
__sympifyit
, but not sure if it has landed in 1.5.1: sympy/sympy@da1d85b
That commit is not in 1.5.1.
I recently updated SymPy Live by pushing 1.5.1. I did test at the time that it was working but probably not extensively so I might have missed an intermittent problem.
There were very few changes between 1.5 and 1.5.1:
https://github.com/sympy/sympy/wiki/Release-Notes-for-1.5.1
If I was to suspect something there it would be the change to ==
comparison. That could affect caching:
sympy/sympy#18084
sympy/sympy#18080
is this still open?,if yes,i want to work towards it.
It seems to have been an intermittent issue. I can't reproduce today using 1/x, 1/x1, or any other expression (tried lots of samples from docs).
Closing now, but will watch out for it in case it comes back.
I don't think anything has changed recently that would have fixed this. It is probably very specific to the full set of commands you ran in the history to reproduce it.