After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 628491 - Sympy module
Sympy module
Status: RESOLVED WONTFIX
Product: reinteract
Classification: Other
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: reinteract-maint
reinteract-maint
gnome[unmaintained]
Depends on:
Blocks:
 
 
Reported: 2010-09-01 10:36 UTC by Jorn Baayen
Modified: 2018-07-10 22:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
resympy module (7.58 KB, text/x-python)
2010-09-01 10:36 UTC, Jorn Baayen
  Details
Updated for new printing system (7.27 KB, patch)
2010-09-06 08:18 UTC, Jorn Baayen
none Details | Review
fix issues (7.21 KB, text/x-python)
2010-09-06 20:21 UTC, Jorn Baayen
  Details
Rebase of resympy.py to trunk (8.96 KB, patch)
2012-07-29 15:00 UTC, Jorn Baayen
none Details | Review

Description Jorn Baayen 2010-09-01 10:36:24 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
Comment 1 Jorn Baayen 2010-09-06 08:18:02 UTC
Created attachment 169549 [details] [review]
Updated for new printing system
Comment 2 Owen Taylor 2010-09-06 18:35:06 UTC
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:

  • File "/home/otaylor/reinteract/lib/reinteract/shell_view.py", line 650 in on_add_custom_result
    widget = result.create_widget()
  • File "/home/otaylor/reinteract/lib/resympy.py", line 175 in create_widget
    return SympyRenderer(self.expr)
  • File "/home/otaylor/reinteract/lib/resympy.py", line 51 in __init__
    self.doc = lasem.mathml_document_new_from_itex(tex, len(tex))
glib.GError: Invalid itex document.

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.
Comment 3 Jorn Baayen 2010-09-06 20:21:53 UTC
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.
Comment 4 Jorn Baayen 2010-09-06 20:23:21 UTC
I'm of course happy to maintain the code -- doing as you suggest sounds great to me.

Thanks!
Comment 5 Jorn Baayen 2012-07-29 15:00:12 UTC
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.
Comment 6 André Klapper 2018-07-10 22:06:09 UTC
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.