New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
log(Abs) #21437
Comments
The problem is that Basic subclasses pass through sympify so this can be fixed with: diff --git a/sympy/functions/elementary/exponential.py b/sympy/functions/elementary/exponential.py
index bdedc455c2..8bf8972000 100644
--- a/sympy/functions/elementary/exponential.py
+++ b/sympy/functions/elementary/exponential.py
@@ -1,4 +1,5 @@
from sympy.core import sympify
+from sympy.core.sympify import _sympify
from sympy.core.add import Add
from sympy.core.cache import cacheit
from sympy.core.function import (
@@ -641,7 +642,7 @@ def eval(cls, arg, base=None):
from sympy.sets.setexpr import SetExpr
from sympy.functions.elementary.complexes import Abs
- arg = sympify(arg)
+ arg = _sympify(arg)
if base is not None:
base = sympify(base) That kind of change should be used throughout much of the codebase. It is probably also good to change it so that sympify rejects Basic subclasses. |
I had thought we had an issue about replacing This is also related to #17280. Really FunctionClass the superclass should handle calling sympify. Classes shouldn't need to do this themselves in |
The proper fix would be to make sympify more strict: diff --git a/sympy/core/sympify.py b/sympy/core/sympify.py
index ed5ba267d9..242cd2e6f3 100644
--- a/sympy/core/sympify.py
+++ b/sympy/core/sympify.py
@@ -346,10 +346,7 @@ def sympify(a, locals=None, convert_xor=True, strict=False, rational=False,
if is_sympy is True:
return a
elif is_sympy is not None:
- if not strict:
- return a
- else:
- raise SympifyError(a)
+ raise SympifyError(a)
if isinstance(a, CantSympify):
raise SympifyError(a) That leads to these failures in core:
The main problem here seems to be that with that change things like In [1]: sin(x).subs(sin, cos)
Out[1]: sin(x)
In [2]: f = Function('f')
In [3]: f(x).subs(f, cos)
Out[3]: f(x)
In [4]: sympify(f)
---------------------------------------------------------------------------
SympifyError Traceback (most recent call last)
<ipython-input-4-f6adfff4c072> in <module>
----> 1 sympify(f)
~/current/sympy/sympy/sympy/core/sympify.py in sympify(a, locals, convert_xor, strict, rational, evaluate)
347 return a
348 elif is_sympy is not None:
--> 349 raise SympifyError(a)
350
351 if isinstance(a, CantSympify):
SympifyError: SympifyError: f: |
log(Abs)
returnszoo
, but the argument oflog
isFunctionClass
.The text was updated successfully, but these errors were encountered: