Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 2663 by [email protected]: sympify with embedded strings does not work since v0.7.0
http://code.google.com/p/sympy/issues/detail?id=2663

As cited in post :
http://groups.google.com/group/sympy/browse_thread/thread/18d1cf15455039de

----------------------------------------------------------------
   Until SymPy v0.6.7, the following was working well :

sympify(u'Limit(sin(x),x,0,dir=\"-\")')

   But with SymPy 0.7.0 or 0.7.1, it gives

"SympifyError: SympifyError: 'could not parse u\'Limit(sin(x),x,
0,dir="-")\''
----------------------------------------------------------------

Aaron Meurer replied :
----------------------------------------------------------------
I bisected the
regression to the commit

commit d00c8b214520604fb65bde426cbaf4f4b30dbba0
Author: Mateusz Paprocki <[email protected]>
Date:   Tue Jun 7 01:55:11 2011 -0700

    Use new parse_expr() in sympify() (#871, #976)

    This makes sympify() independent of parsing tools in Python's
    standard library and makes it much simpler. parse_expr() uses
    modified tokenize module to split an input string into tokens,
    then it applies SymPy-specific transformations, untokenizes
    transformed token sequence and passes resulting string directly
    to eval(). All transformations from old sympify() are supported,
    but lambda -> Lambda conversion. It is possible to implement
    this in the new parse_expr(), but it would make it a little more
    complex, so for now I skipped it, as this kind of transformation
    isn't used very often anyway (lambda tests were XFAILed).

    This also fixes issue #976 and allows sympify() to handle very
    large expressions, e.g.:

    In [1]: e = expand((x + y + z)**50)

    In [2]: s = str(e)

    In [3]: %time sympify(s) == e
    CPU times: user 27.13 s, sys: 0.09 s, total: 27.22 s
    Wall time: 27.22 s
    Out[4]: True

    Previously it raised RuntimeError. Speed could be improved, by
    improving tokenize module.

    Old parsers (ast and ast2.4) are still available and we could
    use them in future to make a more advanced version of sympify()
    that doesn't care about speed and platform compatibility, but
    about generality of transformations, thus we could restore
    lambda support this way (e.g. sympify("...", parser="ast")).
----------------------------------------------------------------

So, the new parser of "sympify" does not work embedded strings which were supported by the old "sympify" (v0.6.7).

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to