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

Skip to content

Remove old normalising code from plt.hist #9121

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 4 commits into from
Oct 19, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add test for density histogram:
  • Loading branch information
dstansby committed Aug 30, 2017
commit 2dde48aed02e63fff1477673735fc3dce388c3bd
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,14 @@ def test_hist_step_filled():
assert all([p.get_facecolor() == p.get_edgecolor() for p in patches])


@image_comparison(baseline_images=['hist_density'], extensions=['png'])
def test_hist_density():
np.random.seed(19680801)
data = np.random.standard_normal(2000)
fig, ax = plt.subplots()
ax.hist(data, density=True)
Copy link
Member

Choose a reason for hiding this comment

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

Does this actually need an image test, or can we just test that np.histogram properly applies the density kwarg?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think there was ever any image test that used the 'density' or 'norm' kwargs, so I thought it would be a good idea to add one.

Copy link
Member

Choose a reason for hiding this comment

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

I think we are trying to keep image tests to things where the actual image appearance might change if code changes. So sure if there is no hist image test there should be one. If such a test does exist then this just tests the value of the bars, and I think you can do that w/o an image comparison. But I’m not passionate about it or anything.

Copy link
Member

Choose a reason for hiding this comment

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

Beating a dead horse, but:

np.random.seed(19680801)
data = np.random.standard_normal(2000)
fig, ax = plt.subplots()
n, bins, patches = ax.hist(data, density=True)
assert np.isclose(np.sum(n * np.diff(bins)), 1.0)



@image_comparison(baseline_images=['hist_step_log_bottom'],
remove_text=True, extensions=['png'])
def test_hist_step_log_bottom():
Expand Down