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

Allow both linestyle definition "accents" and dash-patterns as linestyle #3772

Merged
merged 12 commits into from May 14, 2015

Conversation

lennart0901
Copy link
Contributor

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.

@tacaswell tacaswell added this to the v1.5.x milestone Nov 9, 2014
@@ -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:
Copy link
Member

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?

@tacaswell
Copy link
Member

modulo some small comments, this looks good to me.

@@ -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])
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are the maintainer. :)

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed that.

@jenshnielsen
Copy link
Member

This is failing due to the issue fixed by #3784

@tacaswell
Copy link
Member

@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!

@lennart0901
Copy link
Contributor Author

Well there is still one little thing left. Patches and Collections do not accept "None" and the like (no line drawn). Shall I try to fix that as well? I'm still not sure if that should be done on backend level or for the artists.

@tacaswell
Copy link
Member

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?)

@lennart0901
Copy link
Contributor Author

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.

@tacaswell
Copy link
Member

Failure is a fluke, restarted 2.6 test.

@WeatherGod
Copy link
Member

ping @tacaswell, the tests pass now.

else:
verbose.report('Unrecognized line style %s, %s' %
(linestyle, type(linestyle)))
linestyle = ls_mapper_r.get(linestyle, linestyle)
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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....

Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Member

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).

@lennart0901
Copy link
Contributor Author

@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) ]
=========================== =================
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdboom @efiring This breaks the doc-string scraping code for the tables in the docs. Should we revert the changes to put ACCEPTS : ... back in or re-work the doc-scraping?

Copy link
Contributor Author

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

@tacaswell
Copy link
Member

My concern with using numpydoc for this is than now it is a run-time dependency, not just a documentation-build dependency.

@lennart0901
Copy link
Contributor Author

I answered on #3859

@tacaswell
Copy link
Member

@lennart0901 This needs a re-base.

…yle for collection, lines and patches.

(code & tests)
@lennart0901
Copy link
Contributor Author

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'])
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

@tacaswell
Copy link
Member

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).

@lennart0901
Copy link
Contributor Author

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'],
Copy link
Member

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?

Copy link
Contributor Author

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...

@efiring
Copy link
Member

efiring commented May 13, 2015

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?

tacaswell added a commit that referenced this pull request May 14, 2015
API/ENH : Allow both linestyle definition "accents" and dash-patterns as linestyle
@tacaswell tacaswell merged commit 6376047 into matplotlib:master May 14, 2015
@tacaswell
Copy link
Member

I concur, this has been sitting far too long.

tacaswell added a commit to tacaswell/matplotlib that referenced this pull request May 14, 2015
efiring added a commit that referenced this pull request May 14, 2015
DOC : revert some documentation changes from #3772
@tacaswell
Copy link
Member

@lennart0901 Thank you for this! Sorry it too so long to get it merged, the hold up was entirely on our end.

@lennart0901
Copy link
Contributor Author

All fine and thanks for preparing the reversion of the docstrings. I'm too busy at the moment.

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

Successfully merging this pull request may close these issues.

Inconsistent linestyle specifications between Line2D and Patch artists
6 participants