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

Edge cases in eventplot are likely broken #7560

Closed
anntzer opened this issue Dec 4, 2016 · 7 comments · Fixed by #22286
Closed

Edge cases in eventplot are likely broken #7560

anntzer opened this issue Dec 4, 2016 · 7 comments · Fixed by #22286
Milestone

Comments

@anntzer
Copy link
Contributor

anntzer commented Dec 4, 2016

The eventplot code currently contains the snippet

        if len(lineoffsets) == 0:
            lineoffsets = [None]
        if len(linelengths) == 0:
            linelengths = [None]
        if len(linewidths) == 0:
            lineoffsets = [None] # oops
        if len(linewidths) == 0:
            lineoffsets = [None] # oops
        if len(colors) == 0:
            colors = [None]

which is certainly incorrect.

@dstansby
Copy link
Member

For reference, some code that currently fails:

import matplotlib.pyplot as plt
plt.eventplot([1, 2, 3], lineoffsets=[], linelengths=[], linewidths=[], linestyles=[], colors=[])

@tacaswell
Copy link
Member

It is not obvious that this is wrong, these values get passed into an EventCollection __init__ which may use it's default in place of the None (but I have not chased down the code path to see if it actually happens).

@oscargus
Copy link
Contributor

I hijack this issue as this is also an edge case.

Is eventplot(1) supposed to work?

It is handled in the code:

if not np.iterable(positions):
positions = [positions]

But breaks later since the content is not a 1D-array.

Replacing the second line with positions = [np.asanyarray([positions])] makes it work, but maybe there should be an error already there?

The docs says:

positions : array-like or list of array-like
A 1D array-like defines the positions of one sequence of events.

Also, (related from the perspective that I am trying to increase test coverage) these two lines seems impossible to trigger:

if len(positions) == 0:
return []

@oscargus
Copy link
Contributor

Considering the original issue, #7602 fixed the copy-paste-error, but was not considered a suitable solution.

What about just deleting those lines? Then there will be an error for empty (not the same length), which is fair enough. Or error already when detected that they are empty? (As they actually do not have to be the same length, just not empty.)

@oscargus oscargus mentioned this issue Jan 22, 2022
6 tasks
@timhoffm
Copy link
Member

Is eventplot(1) supposed to work?

I'd say no. It's not documented to work, it does not work and nobody has complained that it should. Making it work would need additional code, documentation and tests. So let's not jump extra hoops here.

@github-actions
Copy link

github-actions bot commented Apr 3, 2023

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Apr 3, 2023
@QuLogic
Copy link
Member

QuLogic commented Apr 4, 2023

There is an open PR for this #22286; I guess a decision needs to be made there, so I added it to the agenda.

@QuLogic QuLogic removed the status: inactive Marked by the “Stale” Github Action label Apr 4, 2023
@oscargus oscargus added this to the v3.8.0 milestone Apr 14, 2023
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 a pull request may close this issue.

6 participants