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
Add EventCollection and eventplot #1669
Conversation
I did something wrong and closed the last pull request. This version has been rebased so it should apply cleanly. |
Is there anything else that needs to be done here? I just tested this and it seems to merge cleanly into master. If everything is okay can someone please merge this when they have a chance? Thanks. There are some other changes I would like to work on but I want to clean up my fork completely before I do so. |
|
||
|
||
@image_comparison(baseline_images=['EventCollection_plot__default']) | ||
def test__EventCollection__get_segments(): |
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.
The double underscores here don't follow PEP8
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.
Are you certain? I just ran it through the pep8 checker and it didn't complain. I also don't see anything in pep8 regarding double underscores except at the beginning and end of names.
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.
Ok. Maybe you're right -- I just always think of double underscores as indicating something "special", which these are not. @NelleV, as our PEP8 expert, what do you think?
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.
Strictly speaking the capital letters are not pep8 compliant, but I don't think double underscore matter in this case, because they don't surround the name (init etc). I do agree with you that it is a bit confusing and I would rather remove them, but this is really nitpicking :)
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 also don't think this should be a roadblock for this PR being merged.
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.
The reason I include them is because it makes it easier to separate out the
method names. So in this example:
test__EventCollection__get_segments
I think it makes it clearer you are testing the get_samples method of
the EventCollection class. At least to me this was less clear when it
was formatted like this:.
test_EventCollection_get_segments
Or
test_eventcollection_get_segments
That is why I went with this approach. I figured there wasn't a
problem with it since the pep8 checker didn't find any problems at all
with 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.
To separate the namespace a bit, you could always create a test class with test methods (akin to unittest.TestCase
but without the straitjacket)...
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 tried using a separate test class. However, the Matplotlib test
decorators do not work inside methods so I had to use the current
approach.
This is not a problem with my code, I could not find any examples of these
decorators being used in classes, Matplotlib tests only use methods of they
are not using the decorators.
Thanks for pinging us about this. matplotlib This looks pretty good, other than my minor comment. This does reveal an unrelated bug in the Agg backend that snapping is not turned on for collections. The lines in these event plots are not getting pixel-snapped, and thus look rather "fuzzy" (at least to my eye). Would you mind also applying the following:
and then regenerating the test baseline images. This will bring the snapping behavior of this inline with the rest of matplotlib. If the user prefers to not have snapping, they can always pass |
I have fixed the bug and submitted updated images for everything that was |
Ok. I think this is good to merge then. I'm going to leave it up for another day for others to comment. I think the Travis failures on this are the same as on master (which I'm still trying to get to the bottom of), so that shouldn't impact merging this. |
Actually -- I take that back. There are a lot more failures here than on master right now. Perhaps rebasing on the current master may help to pick up any recent bugfixes there. I'll see what sort of test failures I'm getting locally with this as well. |
I've found the issue: somehow |
I did as you suggested. I then compared the test results on master to this branch, and the failures are the same. I also re-tested the merge and it still worked. It doesn't look like travis is going to update the test since it doesn't seem to recognize the squashing I did. But a local test had the same failures in master (confirmed up-to-date) and this branch. So everything seems to be fine. |
Yeah -- it's not always clear to me when Travis chooses to pick up PRs and test them either. I'll leave this up for another 24 hours in case there are further comments, but otherwise, I think this is good for merging. |
Great! Thanks a lot. |
I'm not confident why this should have ~420 files changed, many of them test result images - is there a reason for doing this as the overall effect will be a massive increase in the repo's size (not necessarily the distribution size though)? If we could avoid doing such a thing, I think it would be worth doing. Cheers, |
I suspect this was an unintentional mistake (perhaps when doing the rebase). There's no reason I can see that all of the baseline images would require updating. @ghost: I can't figure out which of these commits is updating all of those files. Can you see if you can update this branch such that |
As you suggested I fixed the big regarding snapping. However, this led to changes in many of the test images. So I then checked These should all be in the commit containing the bug fix, the last commit |
Thanks for the explanation. When I make my suggested change (to _backend_agg.cpp) directly on master, I don't get any test failures, so I'm surprised it's failing for you. Let me have a closer look at the images to see what's up. |
Sorry -- my bad. It was just an environmental problem on my end. I indeed see that with my change there are a number of changes to the test images (all improvements, IMHO), so it does make sense to update those images. We'll have to carefully coordinate with #1291, which also has some baseline image updates. |
Travis seems to be failing only on the stackplot test -- which is a different failure than master is currently getting. This is, of course, very close, and thanks for all your hard work. I'll try to reproduce locally and see if anything obvious pops out. |
This issue is not really directly related to these plot types. It looks Would it be okay if I remove bugfix from this PR? That way we can get the |
Your proposal makes sense to me. Snapping problems may be revealed by your PR, but they are separate, and should be dealt with separately. Maybe the ideal would be fix the snap problem, and update images as necessary, and then rebase and merge your PR, with sample images that are correct from the start. But this would be advisable only if the snap fix is imminent. |
The problem is that there are a bunch of failing tests. I think these Using the font example mentioned earlier, what if that problem is due to We don't know how many such incorrect figures there may be, and now telling That is why I would like to get these new figures merged now. There is no |
I have removed the the snapping fix for the reasons mentioned previously. So would it be possible to go ahead and get this merged? |
Add EventCollection and eventplot
Just saw this in the 1.3.0 announcement, very nice! How about a feature, where the values on the y-axis are named items, like {'Event1': 10, 'Event2': 20} ? |
@michaelaye Can you make a new issue with that request? |
As discussed in the mailing list, here is the event plot. It's purpose it to plot one or more series of 1D data points along horizontal or vertical lines. It is dived into two parts.
The first part is the EventCollection collections class, which is a subclass of LineCollection that makes it easy to create and manipulate individual rows of vertical lines or columns of horizontal lines. Besides being used in the final plot type, this is also useful on its own, for example for marking the locations of data points along an axis (see eventcollection_demo.py). Besides the convenience functions, since it is a subclass of LineCollection it also exposes all internal LineCollection and Collection methods, allowing more fine-grained modifications for artists.
The second part is an axes method (also in pyplot through boilerplate.py) which is given one or more rows of data points and creates corresponding rows or columns of lines. All rows or columns can be given the same line properties or individual line properties (see eventplot_demo.py). It returns a list of EventCollection objects.
Tests for both EventCollection and eventplot are present, and the files have been tested for pep8 compliance and run through pyflakes and pylint and fixed wherever appropriate.