Skip to content

Edge cases in eventplot are likely broken #7560

Closed

Description

@anntzer

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.

Activity

  1. dstansby commented on Dec 10, 2016

    @dstansby
    Member

    For reference, some code that currently fails:

    import matplotlib.pyplot as plt
    plt.eventplot([1, 2, 3], lineoffsets=[], linelengths=[], linewidths=[], linestyles=[], colors=[])
    
  2. tacaswell commented on Dec 10, 2016

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

  3. oscargus commented on Jan 22, 2022

    @oscargus
    Member

    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 []

  4. oscargus commented on Jan 22, 2022

    @oscargus
    Member

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

  5. timhoffm commented on Jan 22, 2022

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

  6. github-actions commented on Apr 3, 2023

    @github-actions

    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!

  7. QuLogic commented on Apr 4, 2023

    @QuLogic
    Member

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

  8. added this to the v3.8.0 milestone on Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions