From cc275dd65d417c67505e692a3a4f438da4a796e5 Mon Sep 17 00:00:00 2001 From: Ondrej Certik Date: Sat, 27 Oct 2007 11:32:22 +0200 Subject: [PATCH] Fixes the sympify("exp(x)") problem, issue 439. --- sympy/core/parser.py | 7 +++++++ sympy/core/tests/test_functions.py | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/sympy/core/parser.py b/sympy/core/parser.py index 5c72c9c..6e4969b 100644 --- a/sympy/core/parser.py +++ b/sympy/core/parser.py @@ -650,6 +650,13 @@ class Identifier(StringBase): obj = Basic.singleton.get(self.string) if obj is not None: return obj() + import sympy + try: + #is self some kind of SymPy function? + return eval(self.string, sympy.__dict__) + except: + #no, it isn't... + pass return Basic.Symbol(self.string) diff --git a/sympy/core/tests/test_functions.py b/sympy/core/tests/test_functions.py index c9aafbe..d2de8dd 100644 --- a/sympy/core/tests/test_functions.py +++ b/sympy/core/tests/test_functions.py @@ -131,3 +131,11 @@ def test_combine(): assert (2*exp(x)*exp(-x)).combine() == 2 assert (x/exp(x)*exp(-x)).combine() == x*exp(-2*x) + + +def test_439(): + v = sympify("exp(x)") + x = Symbol("x") + assert v == exp(x) + assert type(v) == type(exp(x)) + assert str(type(v)) == str(type(exp(x))) -- 2.11.4.GIT