-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Allow both linestyle definition "accents" and dash-patterns as linestyle #3772
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
Conversation
@@ -957,8 +972,8 @@ def set_linestyle(self, linestyle): | |||
break | |||
|
|||
if linestyle not in self._lineStyles: | |||
if linestyle in ls_mapper: | |||
linestyle = ls_mapper[linestyle] | |||
if linestyle in ls_mapper_r: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use the same ls_mapper_r.get(ls, ls)
pattern used above?
modulo some small comments, this looks good to me. |
1bb7fab
to
f46a56a
Compare
@@ -2108,7 +2108,10 @@ def unmasked_index_ranges(mask, compressed=True): | |||
(':', 'dotted')] | |||
|
|||
ls_mapper = dict(_linestyles) | |||
ls_mapper.update([(ls[1], ls[0]) for ls in _linestyles]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be neurotic, but should this be documented in api_changes.rst?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are the maintainer. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some order in the file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be more-or-less by date. Can you actually throw it into this folder (https://github.com/matplotlib/matplotlib/tree/master/doc/api/api_changes)? This is an attempt to alleviate the merge conflicts in the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argh, to late I just added a note at the end of the Changes 1.4.x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It definitely should not go there as I don't think this is going to be back-ported to the 1.4 series.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed that.
73db6d3
to
50613a0
Compare
This is failing due to the issue fixed by #3784 |
@mdboom @efiring @pelson @WeatherGod Can one of you have a look at this? It looks good to me, but given that this touches things rather deep in the library I would like a second opinion. @lennart0901 One more documentation thing, can you also add an entry in the whats_new folder? The purpose of that is to advertise in the release notes the changes and I think unifying the linestyle inputs is worth advertising! |
Well there is still one little thing left. Patches and Collections do not accept |
I think that should be fixed in a different PR. I am always going to favor more small PRs over fewer bigger ones. If I understand everything right, as-is this is a major improvement and (almost) unifies the api and nothing is broken due to this omission. I am not sure if no-line makes sense for patches/collections (I think it turns into zero-width edges?) |
Exactly, it would be an alternative to zero width. |
Failure is a fluke, restarted 2.6 test. |
ping @tacaswell, the tests pass now. |
else: | ||
verbose.report('Unrecognized line style %s, %s' % | ||
(linestyle, type(linestyle))) | ||
linestyle = ls_mapper_r.get(linestyle, linestyle) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this still raise an exception if linestyle
is not in either set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In [2]: ln, = plt.plot(range(5))
In [8]: ln.set_linestyle('aardvark')
In [9]: plt.draw()
does not raise an exception, but I think it should.
I have a feeling I suggested you make this change and have now changed my mind about it, sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a PR in against your branch to fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and seems to break a whole lot of other things....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are referring to your PR, aren't you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lennart0901 The test failure should be fixed up now (fingers crossed on travis).
@tacaswell: I merged your PR. |
@@ -463,16 +463,33 @@ def set_linestyle(self, ls): | |||
""" | |||
Set the linestyle(s) for the collection. | |||
|
|||
ACCEPTS: ['solid' | 'dashed', 'dashdot', 'dotted' | | |||
(offset, on-off-dash-seq) ] | |||
=========================== ================= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a PR to demonstrate docscraping using numpydoc: #3859
859dac2
to
8d00efb
Compare
My concern with using numpydoc for this is than now it is a run-time dependency, not just a documentation-build dependency. |
I answered on #3859 |
@lennart0901 This needs a re-base. |
…yle for collection, lines and patches. (code & tests)
8d00efb
to
482c909
Compare
I updated the baseline image of the test that failed. Somehow text spacings changed slightly. |
@@ -325,6 +325,18 @@ def test__EventCollection__set_linestyle(): | |||
splt.set_title('EventCollection: set_linestyle') | |||
|
|||
|
|||
@image_comparison(baseline_images=['EventCollection_plot__set_ls_dash']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add the "remove_text=True" kwarg and update the test image if you aren't going to test text. This helps deal with the tiny differences that occur with different versions of freetype.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case we also had a known 'remake all the tests' change to text layout PR in between.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tacaswell Thanks for the reminder. I havn't touched mpl code for a while now. I'll check the Changelog more regulary.
The test is corrected now.
14345ca
to
b8ced84
Compare
Can you also do some re-basing to remove the images we are not using from the history? We are trying to keep the repository size down (or to keep it from getting any bigger than it currently is). |
… seperate image (to allow multiprocess testing...) and remove text
…getting getting value from ls_mapper_r
Added check in code + test for raise
b8ced84
to
937248d
Compare
Done. Also squashed moving the api_changes from api_changes.rst to the api_changes folder into the commit where the documentation is first created. |
@@ -325,6 +325,19 @@ def test__EventCollection__set_linestyle(): | |||
splt.set_title('EventCollection: set_linestyle') | |||
|
|||
|
|||
@image_comparison(baseline_images=['EventCollection_plot__set_ls_dash'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a question: does this need to test all of the backends, or can it target specific ones? e.g., is a png test sufficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be ok to test just one backend. I only want to test that the linestyle is set and interpreted correctly.
But I think that is true for a number of tests in this file...
It looks like this is held up by the doc formatting change, correct? Maybe it makes sense to revert that part of the change and then merge this? |
API/ENH : Allow both linestyle definition "accents" and dash-patterns as linestyle
I concur, this has been sitting far too long. |
DOC : revert some documentation changes from #3772
@lennart0901 Thank you for this! Sorry it too so long to get it merged, the hold up was entirely on our end. |
All fine and thanks for preparing the reversion of the docstrings. I'm too busy at the moment. |
This is a first PR in an attempt to split #3265 in smaller pieces.
This part should cover the original intent to fix #2136.
The reverse mapper is necessary here to convert full line style names in short ones for lines.py.