X Tutup
Skip to content

Minor cleanup of hist().#7481

Merged
tacaswell merged 1 commit intomatplotlib:masterfrom
anntzer:cleanup-hist
Nov 19, 2016
Merged

Minor cleanup of hist().#7481
tacaswell merged 1 commit intomatplotlib:masterfrom
anntzer:cleanup-hist

Conversation

@anntzer
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

NelleV commented Nov 18, 2016

LGTM
Thanks @anntzer !

@tacaswell tacaswell merged commit f550f8b into matplotlib:master Nov 19, 2016
@tacaswell
Copy link
Copy Markdown
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

X Tutup