GNOME Bugzilla – Bug 628491
Sympy module
Last modified: 2018-07-10 22:06:09 UTC
Created attachment 169226 [details] resympy module The attached module implements a renderer for Sympy [1] objects using (py)lasem [2, 3]. [1] http://www.sympy.org [2] http://git.gnome.org/cgit/lasem [3] http://github.com/jbaayen/pylasem
Created attachment 169549 [details] [review] Updated for new printing system
Little difficult to try out, created Fedora packages and filed review requests: lasem: https://bugzilla.redhat.com/show_bug.cgi?id=630681 pylasem: https://bugzilla.redhat.com/show_bug.cgi?id=630683 (The Fedora package review backlog is pretty big, so I'm not expecting immediate action unless I trade package reviews with someone. But having the review requests filed will let someone else find my work rather than duplicating it.) Also, sympy is not working at all in Fedora 13 though a rebuilt version of the Fedora 14 package works fine: https://bugzilla.redhat.com/show_bug.cgi?id=602431 Once I got past those hurdles, very neat! The first example on http://code.google.com/p/sympy/ actually fails: import resympy from sympy import * x = Symbol('x') e = 1/cos(x) e.series(x, 0, 10) Produces on stdout:
+ Trace 223567
widget = result.create_widget()
return SympyRenderer(self.expr)
self.doc = lasem.mathml_document_new_from_itex(tex, len(tex))
But other examples I tried worked nicely. The plotting functionality you have doesn't match up with my version of sympy which seems to have plotting based on pyglet rather than on matplotlib. Not sure what's going on there. The code looks very nice, found just a few things looking through it. our do_screen_changed() and do_parent_set() handlers assume that you are always going from object => None or None => object. They don't disconnect properly in the object => object case. I don't think that's true for the screen, though it's probably true for the parent. For both it's better style I think not to make that assumption. Not your fault, but: self.view.set_cairo Guess my campaign "there is no such thing as a Cairo" didn't get through. http://cairographics.org/manual/language-bindings.html. Filed against lasem as: https://bugzilla.gnome.org/show_bug.cgi?id=628912 Do you need the cached contents cairo surface? *Most* of the time double buffering doesn't make sense and it's better to just redraw as necessary. replot uses a cache because rendering certain plots can take a long time. (I think. It's been a while since I wrote that code.) There is points-pixels fudging in the printing code for margin handling - you use the same value for pixels in the screen drawing code and points in the printing code I can't complain because I did exactly the same thing in worksheet_print.py, but it should at least be marked. x, y = cr.get_current_point() view.set_cairo(cr) view.render(x + SympyRenderer.margin_left, y + SympyRenderer.margin_top + height) Is wrong - the current point is not involved. When print_result() is called, the context is translated so that x = 0 is at the left margin and y = 0 is at the top of the space you need to render in. I think you want: view.render(SympyRenderer.margin_left, SympyRenderer.margin_top) In terms of maintenance, if you want this module included as part of Reinteract, I'm happy to do it. I think it fits in well with the mission of Reinteract. I'll try to to keep to the "Linux driver" model - if you have changes you want me to merge, let me know, and I'll merge them and only review the changes if you ask for them to be reviewed. I don't know yet if I'd include sympy and lasem and pylasem next time I make packages for OS X and Windows. sympy is pretty small compared (say) to matplotlib, but the approach of just bundling everything has its limits.
Created attachment 169615 [details] fix issues Re the series example: I think \mathcal isn't valid itex. I'll produce a patch for sympy. I added the double buffering because lasem can be quite slow. Worksheets feel a lot snappier with the caching in. I'm attaching a new version of resympy.py incorporating your suggestions. Apologies for this not being in patch format.. I managed to screw up my git branches.
I'm of course happy to maintain the code -- doing as you suggest sounds great to me. Thanks!
Created attachment 219843 [details] [review] Rebase of resympy.py to trunk This is a rebase of the old code to trunk, fixing the signal handler issues. The 'set_cairo' API change has still not hit any lasem release, so I've not changed this in my code. The double-buffering is intentional: Lasem does take a little time to render, and scrolling pages with many equations becomes jerky without the double buffer.
Reinteract is not under active development anymore and had its last code changes in early 2012: http://git.fishsoup.net/cgit/reinteract/log/ Closing this report as WONTFIX as part of Bugzilla Housekeeping to reflect reality. Please feel free to reopen this ticket (or rather transfer the project to GNOME Gitlab, as GNOME Bugzilla is deprecated) if anyone takes the responsibility for active development again.