-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Minor cleanup of hist(). #7481
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
Minor cleanup of hist(). #7481
Conversation
else: | ||
boffset = 0.0 | ||
stacked = False | ||
boffset = -0.5 * dr * totwidth * (1 - 1 / nx) |
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.
Doesn't this introduce the possibility of divide-by-zero?
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.
l.6284 also divides by nx, so if nx is 0, we already to a divide-by-zero.
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.
Good point.
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.
if nx
is zero, then there is no data so other things are confused as well.
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.
It seems to me that due to l. 6176-6181 (and above), the case nx == 0
should never occur: the case where the input is empty is preprocessed to have a length of 1.
# Massage 'x' for processing.
if input_empty:
x = np.array([[]])
else:
x = _normalize_input(x, 'x')
nx = len(x) # number of datasets
LGTM |
As much as touching |
Mostly style, use
clip
, get rid of a redundant conditional.