Tuesday, September 29, 2009

SymPy + Reinteract = ♥

Part of what makes SymPy so useful is the fact that it can readily be combined with any other Python software. Nevertheless I sometimes find myself wishing for a better interactive shell, where one can go back and edit previous statements. Reinteract is the obvious candidate and the only thing that kept me back was its lack of support for SymPy's "pretty printing". Now I've just found a bit of time to combine the two:

The drawback of using LaTeX is that for every formula an external program has to be invoked. This can become slow for large worksheets, and so I've experimented with embedding GtkMathView as well. GtkMathView currently breaks when scrolling the Reinteract text view, but I'm sure this can be fixed. Otherwise it works well enough for a screenshot:

Both are quite horrible hacks currently but I promise to polish. Thus far I offer (incomplete) Python bindings for GtkMathView and a Reinteract branch. The LaTeX formatter makes use of latexmath2png.py.


Anonymous said...

Thank you for a nice article ! :)

Max said...

who generates the latex sympy or reinteract?

David said...

Check out Mathtex, it's the reimplemented renderer from matplotlib spun off into its own project. It should be able to render bitmap data to whatever canvas you like, and it's more portable than GTKMathView. :)