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

eventplot raises an exception for empty sequences #2786

Closed
jgosmann opened this issue Feb 3, 2014 · 0 comments
Closed

eventplot raises an exception for empty sequences #2786

jgosmann opened this issue Feb 3, 2014 · 0 comments
Milestone

Comments

@jgosmann
Copy link

jgosmann commented Feb 3, 2014

plt.eventplot([[]], colors=[(0.0, 0.0, 0.0, 0.0)])
will fail with the following exception:

/home/jgosmann/virt_env/default/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/pyplot.pyc in eventplot(positions, orientation, lineoffsets, linelengths, linewidths, colors, linestyles, hold, **kwargs)
   2718                            lineoffsets=lineoffsets, linelengths=linelengths,
   2719                            linewidths=linewidths, colors=colors,
-> 2720                            linestyles=linestyles, **kwargs)
   2721         draw_if_interactive()
   2722     finally:

/home/jgosmann/virt_env/default/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/axes.pyc in eventplot(self, positions, orientation, lineoffsets, linelengths, linewidths, colors, linestyles, **kwargs)
   3987 
   3988         if len(positions) > 0:
-> 3989             minpos = min(position.min() for position in positions)
   3990             maxpos = max(position.max() for position in positions)
   3991 

/home/jgosmann/virt_env/default/local/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/axes.pyc in <genexpr>((position,))
   3987 
   3988         if len(positions) > 0:
-> 3989             minpos = min(position.min() for position in positions)
   3990             maxpos = max(position.max() for position in positions)
   3991 

/home/jgosmann/virt_env/default/local/lib/python2.7/site-packages/numpy/core/_methods.pyc in _amin(a, axis, out, keepdims)
     19 def _amin(a, axis=None, out=None, keepdims=False):
     20     return um.minimum.reduce(a, axis=axis,
---> 21                             out=out, keepdims=keepdims)
     22 
     23 def _sum(a, axis=None, dtype=None, out=None, keepdims=False):

ValueError: zero-size array to reduction operation minimum which has no identity

I think, this case should be handled more gracefully. Having a timeslice without any events can be a quite standard thing depending on the analysis one performs. Having to handle this special case always outside the function before plotting can be quite annoying (and one has also take care of labels matching after removing empty sequences out of the list).

@tacaswell tacaswell added this to the v1.4.x milestone Feb 3, 2014
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

No branches or pull requests

2 participants