-
-
Notifications
You must be signed in to change notification settings - Fork 509
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
image dimensions for show() are in inches #5956
Comments
comment:3
Made a doc update after reading this thread: https://groups.google.com/forum/?fromgroups=#!topic/sage-devel/xBElS3vAu5c Do you think any more info should be included in the changes? |
Author: emchennyc |
Reviewer: Karl-Dieter Crisman |
comment:5
This would be a good start. What's the reference for the dpi, just out of curiosity? (I assume it's right in the Sage or mpl source.) Also, telling us the maximum possible would be helpful, given the errors - especially since the one above is confusing since the
So this should be very, very clear, in order to resolve this ticket. Additionally, you'll want to add a doctest to verify that some things don't go boom, and that the error is correctly raised, etc. Maybe even a Finally, we may also want to report the segfault upstream with a "pure" matplotlib example, if you can concoct one. But all that said, thanks very much for looking at this - this is just part of the normal review process, good start. |
Changed author from emchennyc to Emily Chen |
comment:6
Thank you for the pointers. In matplotlib/rcsetup.py the default figure properties start at line 508. I submitted a new patch to include what I think you mean by a doctest. I wasn't sure what you meant about including '# not tested line with the segfault'. Should I include an example with the segfault in the docstring? Strangely enough, I did not raise any errors when I tried a 'pure' matplotlib example...
Would someone kindly review and let me know what else should be included in the doctest? I appreciate your patience with this, as I am (obviously) new and hoping to learn. Thank you! |
Upstream: None of the above - read trac for reasoning. |
comment:7
This ticket is awesome! Brought my laptop to a crawl! :) @sagetrac-emchennyc: I might come back to this ticket if kcrisman doesn't. For now, it seems that matplotlib (even the latest 1.2.0 release) does not handle the parameters What kcrisman asks is a doctest like this (under a
If you do happen to run this command, be very careful. I suggest you set a ulimit before you start sage. If you have, say 3G, of memory/RAM, then set ulimit to 2G and only then start sage. If you have even less memory then you will need to set even lower ulimit, but sage won't run properly below 1G.
That said, I would like you to set some defaults in your editor. Currently, your patch contains a mixture of tabs and spaces. I suggest you change the settings in your editor to not insert tabs, and instead insert 4 spaces every time you press a tab key. |
comment:8
Needs work due to the issues raise by ppurka, but getting close! |
comment:9
@ppurka Thank you for the feedback! The tests I included in the attached patch pass when I run: Then, I
Also, here is a matplotlib example which I believe this bug is related to. Please correct me if I'm wrong and feel free to advise if I should use this example to report as a matplotlib issue: http://pastebin.com/raw.php?i=5Arg52e2 |
comment:10
Replying to @sagetrac-emchennyc:
You have to do ./sage -b first. The tests run on the copy of the code in the devel/sage directory, but the docs build off the ones in the build directory which that command does.
|
comment:11
Thanks for the update. There is one more thing that I overlooked earlier. The documentation should mention that the number
I think the following modification to the
Then, the test should have the following description:
This will make the number 32768 more clear to anyone who is curious what that number means in the I am unable to replicate your matplotlib example. A figure doesn't seem to have a
|
Attachment: trac_5956_figsize_units.patch.gz |
Attachment: trac_5956_figsize_units.1.patch.gz apply only this |
Attachment: only_for_review.patch.gz not to be merged. only for review. |
This comment has been minimized.
This comment has been minimized.
comment:12
Updated the patch to sage-5.7beta0 and introduced some other changes. The patch attachment: only_for_review.patch contains the changes I made after rebasing the patch to 5.7beta0. In particular, I have introduced the changes I suggested in my comments, and have fixed failing doctests due to the use/redefining of The changes needs review. Patchbot apply trac_5956_figsize_units.1.patch |
Changed branch from u/ppurka/ticket/5956 to u/kcrisman/figsize |
comment:32
Replying to @ppurka:
Well, it could be that the user will send some Sage numeric type, which matplotlib might treat like garbage. A conversion like
will solve both problems: it will raise a |
This comment has been minimized.
This comment has been minimized.
comment:34
A minor point, but I wouldn't write segfaulting examples. Imagine the user tries those "examples" without reading the surrounding text... |
comment:35
Replying to @jdemeyer:
How about we prepend the segfaulting line with a comment? Like this:
So, anyone who blindly copy pastes will get nothing out of it. And has to make two mistakes to make it segfault. I think the reason this example is there is to make the user aware that unreasonable parameters will result in an uncomfortable end. |
comment:36
That sounds very reasonable. Jeroen, are you saying that my latest commit needs something added like the |
Changed reviewer from Karl-Dieter Crisman, Punarbasu Purkayastha to Karl-Dieter Crisman, Punarbasu Purkayastha, Jeroen Demeyer |
comment:39
Is there a check that I would change the logic of those branches to
And add a doctest for some non-float
|
comment:40
The |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:42
Okay, that's what I can do today. If you really want the code reorganized that badly it will have to fall to you, I'm afraid. But everything else should be taken care of. |
comment:43
I think you have addressed Jeroen's concerns. |
Changed branch from u/kcrisman/figsize to |
comment:45
Followup #17057. |
Changed commit from |
As discussed at this sage-devel thread, the optional argument
figsize
of the commandshow()
needs to clearly state that the units of the image are in inches. As of Sage 3.4.1, the docstring forshow()
says:which can be interpreted to mean that one can do something like
figsize=[w,h]
. But something like the following produces a segmentation fault:while the following results in a
ValueError
:Essentially, the documentation for
show()
needs to be updated, especially the optional arguments, to clearly explain the units of measurement of the width and height of the image size. Also, it would be a good idea to specify how one can pass in values for those dimensions. For example, can one do thisfigsize=[124,124]
?Upstream: None of the above - read trac for reasoning.
CC: @kcrisman
Component: graphics
Keywords: image dimensions, figsize
Author: Emily Chen, Punarbasu Purkayastha, Karl-Dieter Crisman
Branch:
4c5b581
Reviewer: Karl-Dieter Crisman, Punarbasu Purkayastha, Jeroen Demeyer
Issue created by migration from https://trac.sagemath.org/ticket/5956
The text was updated successfully, but these errors were encountered: