Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 1 commit into from
Nov 19, 2016
Merged

Minor cleanup of hist(). #7481

merged 1 commit into from
Nov 19, 2016

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Nov 17, 2016

Mostly style, use clip, get rid of a redundant conditional.

else:
boffset = 0.0
stacked = False
boffset = -0.5 * dr * totwidth * (1 - 1 / nx)
Copy link
Contributor

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?

Copy link
Member

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

Copy link
Member

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.

Copy link
Contributor

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

@NelleV NelleV changed the title Minor cleanup of hist(). [MRG+1] Minor cleanup of hist(). Nov 18, 2016
@NelleV
Copy link
Member

NelleV commented Nov 18, 2016

LGTM
Thanks @anntzer !

@tacaswell tacaswell merged commit f550f8b into matplotlib:master Nov 19, 2016
@tacaswell
Copy link
Member

As much as touching hist makes me nervous....

@anntzer anntzer deleted the cleanup-hist branch November 19, 2016 18:34
@QuLogic QuLogic added this to the 2.1 (next point release) milestone Nov 20, 2016
@QuLogic QuLogic changed the title [MRG+1] Minor cleanup of hist(). Minor cleanup of hist(). Nov 28, 2016
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 this pull request may close these issues.

6 participants