-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix #5572: Allow passing empty range to broken_barh #5600
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
Conversation
self._process_unit_info(xdata=xranges[0], | ||
ydata=yrange[0], | ||
if len(xranges): | ||
xdata = xranges[0] |
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.
Probably safer to do xdata = next(iter(xrange))
in a try...except
block. pandas Series
slice on index rather than position
try:
xdata = next(iter(xranges))
except (StopIteration, TypeError):
xdata = None
I dimly recall seeing this sort of pre-processing prior to _process_unit_info elsewhere; does it need to be factored out? E.g., could it be added to _process_unit_info itself, perhaps activated with a kwarg? Is there also a Pandas conversion stage that we are stuck having to use now, so that we don't end up sprinkling things like six.next(iter(xxx)) all over the place? |
This is now ready to merge. |
self._process_unit_info(xdata=xranges[0], | ||
ydata=yrange[0], | ||
if len(xranges): | ||
xdata = six.next(iter(xranges)) |
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 think we can just use next
here https://docs.python.org/2/library/functions.html#next I think six
provides it to support back to 2.4 or something like that.
Fix #5572: Allow passing empty range to broken_barh
Fix #5572: Allow passing empty range to broken_barh
backported as 8228dbd |
No description provided.