symengine.py icon indicating copy to clipboard operation
symengine.py copied to clipboard

Passing locals dict to sympify

Open zaprice opened this issue 5 years ago • 1 comments

When constructing an expression from a string in SymPy, it is often useful to pass around a locals dict defining necessary symbols. This functionality is present in sympy.sympify via the argument locals, and in sympy.parsing.sympy_parser.parse_expr via the argument local_dict.

Rather than declaring them in the local environment and constructing an expression with eval, we can pass around a dict of symbols resulting in cleaner code (e.g. no linter complaints about variables only used inside eval, re-use is more straightforward, etc).

It would be nice to have this in symengine.py as well!

zaprice avatar May 21 '20 23:05 zaprice

Yes, we'd like to have this. Let me know if you'd like to work on this and I can give pointers and help you with it.

isuruf avatar May 22 '20 01:05 isuruf