-
-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor GraphicsArray, fixing various issues #27865
Comments
Commit: |
Last 10 new commits:
|
Branch: public/graphics/multi_graphics |
Author: Eric Gourgoulhon |
This comment has been minimized.
This comment has been minimized.
Attachment: graphics_array_bug.png |
Attachment: graphics_array_ok.png |
comment:3
Here is an example summarizing some the
results in this figure: We see that
With the code introduced in this ticket, the output becomes We see that all the above issues are gone. |
comment:5
Another bug fixed by this ticket regards the options passed to the method
has obviously some axes and no frame... Compare with the figure produced by the code in this ticket here. |
This comment has been minimized.
This comment has been minimized.
comment:7
THIS IS AMAZING! I (as usual the past few years, I am sorry) will not be able to provide code review. But I think this is a great improvement. The multigraphics examples at the end of the example page are particularly impressive, and bring us a long ways toward having a "mathematical" way to interface with the stuff matplotlib provides - I could imagine it being particularly helpful with SageTeX. Thank you. As my only suggestion, I would just urge you to be sure all previously "wrong" behavior shows up in the tests section, and that any errors be tested as well. As an example, you mention
so might as well put in
or whatever is appropriate. We've definitely caught subtle things over the years with those kinds of tests. |
comment:8
Replying to @kcrisman:
OK, no problem, I'll introduce these tests. |
comment:10
During the preparation of this ticket, two questions arose:
|
comment:11
some failing doctests, see patchbot reports |
comment:13
Replying to @fchapoton:
From all the errors reported bu the patchbots, it seems that only one pertains to this ticket:
This doctest is passed on my computer (Ubuntu 18.04). It fails on macOS patchbots. The reason seems to be this Matplotlib issue: Actually, this doctest was borrowed from the previous method I have restored the The patchbots also complain about 4 pyflakes issues. However, these reports are spurious for 2 of them:
=> if one suppresses this import, then the documentation fails to build (stating that
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:15
Replying to @egourgoulhon:
I've prepared the |
comment:16
Replying to @kcrisman:
Actually, the previous wrong behaviors were "silent" errors, which showed up only in the figures, as illustrated in comment:3. Their fixes therefore cannot be checked in doctests. I've however chosen the doctests in the EXAMPLES section of |
comment:17
It seems there is no longer any failing doctest reported by the patchbots (except for spurious ones, i.e. failures that appear on the ticket 0 as well: https://patchbot.sagemath.org/ticket/0/)... |
comment:18
Oh, that was all I meant. Yes, at one point we considered trying to automate doctesting the images themselves (!) but especially now that a lot of images are created for the documentation, regressions should be easier to identify, and we would like to have those available. Thanks! |
comment:19
I am giving a positive review. This is a very nice progress, that fixes a whole lot of long-standing bugs. Fixed tickets will have to be closed later, with appropriate doctests if necessary. |
Reviewer: Frédéric Chapoton |
comment:20
Replying to @fchapoton:
Thanks for the review! |
Changed branch from public/graphics/multi_graphics to |
comment:22
Not in Sage 8.8. Let's please to try keep tickets' milestones related to the release in which we actually intend to include them, and in particular the release in which they were actually included, especially when closing tickets. |
This ticket makes
GraphicsArray
derive from a new class,MultiGraphics
, which is more generic (arbitrary positions of graphics objects on a canvas) and paves the way towards graphics insets in #27866.GraphicsArray
is now endowed with amatplotlib()
function (inheritated fromMultiGraphics
). This fixes the issues reported in #10466, #10657, #11160 and #12591 (see :comment:3 and comment:5 below for a summary).Moreover, this simplifies
sphinx_plot()
(defined insrc/doc/common/conf.py
), avoiding code duplication.Beside introducing
matplotlib()
at the graphics array level, two bugs had to be corrected inGraphics.matplotlib()
:_set_scale
was called on the whole figure, while it should be called on the current subplottick_params
was called onfigure.get_axes()[0]
, i.e. the first subplot of the figure, while it should be called on the current subplot.The documentation of
Graphics.matplotlib()
is also improved in this ticket.Another bug has been corrected in
Graphics.save()
: contrary to what was claimed in the documentationg.save("filename")
with"filename"
having no extension did not save in asobj
file but yielded to an error.Another modification is the introduction of the helper function
_parse_figsize()
insrc/sage/plot/graphics.py
to avoid code duplication: it is used inGraphics.matplotlib()
,MultiGraphics.matplotlib()
andsphinx_plot()
.Since the file
src/sage/plot/graphics.py
was already quite long (3736 lines!), the classGraphicsArray
was moved to the new filesrc/sage/plot/multigraphics.py
, which contains the definition of the base classMultiGraphics
. This makes things more consistent:src/sage/plot/graphics.py
: onlyGraphics
objectssrc/sage/plot/multigraphics.py
: onlyMultiGraphics
objectsBesides the bugs reported in the tickets #10466, #10657, #11160 and #12591, this ticket fixes two other bugs:
if any plot in the array had a log scale, the latter was erroneously applied to the first plot of the array
the computation of
nrows
andncols
in the functiongraphics_array()
(defined insrc/sage/plot/plot.py
) yielded unnecessary large numbers in certain cases. For instance we have in Sage 8.7:with the second raw that is entirely blank. With the code in this ticket the output is
This fix explains the change of doctest outputs in
src/sage/categories/finite_posets.py
andsrc/sage/repl/rich_output/pretty_print.py
A preview (including the functionalities introduced in #27866) is available here.
CC: @kcrisman @fchapoton @dkrenn @jdemeyer @embray
Component: graphics
Keywords: graphics_array, matplotlib
Author: Eric Gourgoulhon
Branch/Commit:
36c0f17
Reviewer: Frédéric Chapoton
Issue created by migration from https://trac.sagemath.org/ticket/27865
The text was updated successfully, but these errors were encountered: