Skip to content
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

Clean up linestyle arguments throughout Sage #13834

Closed
ppurka opened this issue Dec 15, 2012 · 25 comments
Closed

Clean up linestyle arguments throughout Sage #13834

ppurka opened this issue Dec 15, 2012 · 25 comments

Comments

@ppurka
Copy link
Member

ppurka commented Dec 15, 2012

The linestyle argument is inconsistent across plots, as already pointed out in #13423. It seems this is spread out throughout many Sage components including sage.plot.* and sage.graphs.graph_plot.


Apply to devel/sage

  1. attachment: trac_13834_enable_short_linestyle.2.patch
  2. attachment: trac_13834-more_linestyle_cleanups.patch

CC: @kcrisman @sagetrac-twch

Component: graphics

Author: Tobias Weich, Punarbasu Purkayastha

Reviewer: Punarbasu Purkayastha, Tobias Weich, Nathann Cohen

Merged: sage-5.11.rc0

Issue created by migration from https://trac.sagemath.org/ticket/13834

@sagetrac-twch
Copy link
Mannequin

sagetrac-twch mannequin commented Apr 6, 2013

comment:3

Attachment: trac_13834_enable_short_linestyle.patch.gz

This patch should enable short matplotlib linestyle keywords like ':' od '--' for arc, arrow, bezier_path, circle and ellipse. Up to now only long linestyle were available.

Furthermore worng linestyle keywords now should lead to a Warning that the linestyle is unknown and ignored but the object is nevertheless plotted with the default linestyle.

@sagetrac-twch sagetrac-twch mannequin added the s: needs review label Apr 6, 2013
@ppurka
Copy link
Member Author

ppurka commented Apr 7, 2013

comment:5

Hello, Thanks for looking into this ticket. I will be able to do a more thorough review only later this week. With a casual look at the patch, I have the following comments about the formatting. In general, you can look at the Sage developer's guide on how to format certain things.

  1. Try to limit the lengths of your lines to about 80 characters. An example of how code can be written to fit within that limit is given in PEP8. Very long lines are hard to read and edit. Long strings can also be broken up like this
    ValueError("this is a valueerror for %d"
               "something something %s.\n"
               "something else"%(20, 'abc'))
  1. Don't try to catch the ValueError that is raised inside the new function get_matplotlib_linestyle. So you can get rid of the try block and import verbose.
  2. In the docstrings, write the strings inside double backticks like this
    - ``linestyle`` - (default: ``'solid'``) The style of the line, which is one of
      ``'dashed'``, ``'dotted'``, ``'solid'`` ....

@sagetrac-twch
Copy link
Mannequin

sagetrac-twch mannequin commented Apr 8, 2013

Attachment: tratrac_13834_enable_short_linestyle2.patch.gz

some improvements proposed by ppurka have been added. Can directly be applied to sage 5.8

@sagetrac-twch
Copy link
Mannequin

sagetrac-twch mannequin commented Apr 8, 2013

comment:6

Hi Basu,

I tried to improve the formatting following your comments and added a new patch.

tobi

@sagetrac-twch
Copy link
Mannequin

sagetrac-twch mannequin commented Apr 8, 2013

Author: Tobias Weich

@ppurka

This comment has been minimized.

@ppurka
Copy link
Member Author

ppurka commented Apr 13, 2013

comment:8

Hi Tobias, your patch is quite good now. It is quite nice of you to have fixed a lot of docstrings.

I also found a bunch of other places where linestyle needed cleanups. It also affected the new function get_matplotlib_linestyle. I have uploaded a patch and it needs a review. If you see anything you don't like or if you think I missed something, feel free to point it out! :)

Patchbot apply tratrac_13834_enable_short_linestyle2.patch trac_13834-more_linestyle_cleanups.patch

@sagetrac-twch
Copy link
Mannequin

sagetrac-twch mannequin commented Apr 17, 2013

comment:9

Hi

thanks for the extensive improvements!

I did the following in order to test the patches:

$ ./sage --testall --long
all tests passed
/sage -docbuild reference html

Built without errors or warnings

checked coverage of changed files:
There are only some old missing coverages in hyperbolic_arc and hyperbolic_triangle. But I'm not sure how one should test them reasonably.

The only thing which seems to be a little bit unlogical for me is:

        301         Linestyles with ``"default"`` or ``"steps"`` in them should also be 
 	302	    properly handled.  For instance, matplotlib understands only the short 
 	303	    version when ``"steps"`` is used:: 
 	304	 
 	305	        sage: get_matplotlib_linestyle("default", "short") 
 	306	        '' 
 	307	        sage: get_matplotlib_linestyle("steps--", "short") 
 	308	        'steps--' 
 	309	        sage: get_matplotlib_linestyle("steps-predashed", "long") 
 	310	        'steps-pre--' 

Wouldn't the following be more reasonable: If matplotlib in some functions only understand linestyles "stepsdashed" the function get_matplotlib_linestyle should be called with the "short" keyword (as you do it in lines.py) but the keyword shouldn't be ignored in the function itself. But I don't see that this makes any problems so its just a question.

I also tried to play with the enhanced functions and encountered no further problems.

In any case: Since I'm inexperienced someone more experienced should have a final look in order to confirm the patches.

@ppurka
Copy link
Member Author

ppurka commented Apr 17, 2013

comment:10

Replying to @sagetrac-twch:

I did the following in order to test the patches:

$ ./sage --testall --long
all tests passed
/sage -docbuild reference html

Built without errors or warnings

Thanks for checking this. The patchbot is down, otherwise it would have checked for all of it.

The only thing which seems to be a little bit unlogical for me is:

        301         Linestyles with ``"default"`` or ``"steps"`` in them should also be 
 	302	    properly handled.  For instance, matplotlib understands only the short 
 	303	    version when ``"steps"`` is used:: 
 	304	 
 	305	        sage: get_matplotlib_linestyle("default", "short") 
 	306	        '' 
 	307	        sage: get_matplotlib_linestyle("steps--", "short") 
 	308	        'steps--' 
 	309	        sage: get_matplotlib_linestyle("steps-predashed", "long") 
 	310	        'steps-pre--' 

Wouldn't the following be more reasonable: If matplotlib in some functions only understand linestyles "stepsdashed" the function get_matplotlib_linestyle should be called with the "short" keyword (as you do it in lines.py) but the keyword shouldn't be ignored in the function itself. But I don't see that this makes any problems so its just a question.

Since get_matplotlib_linestyle is an internal function I just made it silently output the correct result even on incorrect input. maptlotlib understands only the short form in those cases and so I think it is safe to output the short form always when we know that there is no alternative.

I also tried to play with the enhanced functions and encountered no further problems.

Thanks for checking them. I had checked some but not all.

In any case: Since I'm inexperienced someone more experienced should have a final look in order to confirm the patches.

Well, let's hope someone comes along and gives the patches a test drive. :)

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Jun 30, 2013

comment:11

Helloooooooooooo !!

There were two rejects when I tried to apply the patches on 5.10.rc1 but short of this it looks good to me. Could you please rebase it ? I will then run all tests and set the ticket to positive_review :-)

Nathann

@ppurka
Copy link
Member Author

ppurka commented Jun 30, 2013

comment:12

The rebased patches doesn't pass doctests in sage-5.11.beta3. This patch needs more TLC.

@ppurka
Copy link
Member Author

ppurka commented Jun 30, 2013

Work Issues: fix doctests

@ppurka
Copy link
Member Author

ppurka commented Jun 30, 2013

comment:13

Well, it seems a bunch of them fail anyway on vanilla sage-5.11.beta3.

sage -t plot/graphics.py  # 1 doctest failed
sage -t plot/plot3d/plot3d.py  # 4 doctests failed
sage -t plot/arrow.py  # 1 doctest failed
sage -t plot/colors.py  # 1 doctest failed

@ppurka
Copy link
Member Author

ppurka commented Jun 30, 2013

Apply to devel/sage (rebased to sage-5.11.beta3)

@ppurka
Copy link
Member Author

ppurka commented Jun 30, 2013

Attachment: trac_13834_enable_short_linestyle.2.patch.gz

Apply to devel/sage (Rebased to sage-5.11.beta3)

@ppurka

This comment has been minimized.

@ppurka
Copy link
Member Author

ppurka commented Jun 30, 2013

comment:14

Attachment: trac_13834-more_linestyle_cleanups.patch.gz

Oops sorry. Sage-5.11b3 was just fine. I was using the wrong sage version to test this directory. Passes all doctests in sage/{graphs,plot}.

Patchbot apply trac_13834_enable_short_linestyle.2.patch trac_13834-more_linestyle_cleanups.patch

@ppurka
Copy link
Member Author

ppurka commented Jun 30, 2013

Changed work issues from fix doctests to none

@ppurka
Copy link
Member Author

ppurka commented Jun 30, 2013

Changed author from Tobias Weich to Tobias Weich, Punarbasu Purkayastha

@ppurka
Copy link
Member Author

ppurka commented Jun 30, 2013

Reviewer: Punarbasu Purkayastha, Tobias Weich, Nathann Cohen

@ppurka
Copy link
Member Author

ppurka commented Jun 30, 2013

comment:15

I also removed some trailing whitespace that I didn't see earlier.

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Jun 30, 2013

comment:16

It also passes all tests on my computers except for unrelated things.. Soooooooooo let it go ! Thank you for this patch :-)

Nathann

@ppurka
Copy link
Member Author

ppurka commented Jun 30, 2013

comment:17

Yay! Thanks. :)

@ppurka ppurka added this to the sage-5.11 milestone Jun 30, 2013
@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Jul 1, 2013

comment:18

Helloooooooooo guys !! If any of you had a split second to give #14805 a review, it would be very very kind. The patch does absolutely nothing, it's just a doc cleaning of a file that was not included in the documentation ^^;

Thannnks you if you can ! Otherwise it's not a very bad problem :-)

Nathann

@jdemeyer
Copy link

Merged: sage-5.11.rc0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants