details: http://hg.sympy.org/sympy/rev/3dc1df0e2151 changeset: 1853:3dc1df0e2151 user: Andy R. Terrel <[EMAIL PROTECTED]> date: Wed Nov 05 09:46:55 2008 +0100 description: Fixes issues 1035 and 1178: -- Issue 1035: Have sympify("x^2") return x**2 -- Issue 1178: Don't use mutable keyword args.
diffs (41 lines): diff -r eeccebd889a8 -r 3dc1df0e2151 sympy/core/sympify.py --- a/sympy/core/sympify.py Wed Nov 05 08:35:12 2008 -0800 +++ b/sympy/core/sympify.py Wed Nov 05 09:46:55 2008 +0100 @@ -14,7 +14,7 @@ return "Sympify of expression '%s' failed, because of exception being raised:\n%s: %s" % (self.expr, self.base_exc.__class__.__name__, str(self.base_exc)) -def sympify(a, locals= {}): +def sympify(a, locals=None, convert_xor=True): """Converts an arbitrary expression to a type that can be used inside sympy. For example, it will convert python int's into instance of sympy.Rational, floats into intances of sympy.Real, @@ -51,6 +51,8 @@ # # When everything settles, let's refactor this. # -- kirr + if locals is None: + locals = {} if isinstance(a, Basic): return a if isinstance(a, BasicType): @@ -114,6 +116,8 @@ a = str(a) try: + if convert_xor: + a = a.replace('^','**') import ast_parser return ast_parser.SymPyParser(local_dict=locals).parse_expr(a) except Exception, exc: diff -r eeccebd889a8 -r 3dc1df0e2151 sympy/core/tests/test_sympify.py --- a/sympy/core/tests/test_sympify.py Wed Nov 05 08:35:12 2008 -0800 +++ b/sympy/core/tests/test_sympify.py Wed Nov 05 09:46:55 2008 +0100 @@ -29,6 +29,7 @@ def test_sympify3(): assert sympify("x**3") == x**3 + assert sympify("x^3") == x**3 assert sympify("1/2") == Integer(1)/2 raises(SympifyError, "_sympify('x**3')") --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-commits" group. To post to this group, send email to sympy-commits@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy-commits?hl=en -~----------~----~----~----~------~----~------~--~---