Skip to content

Replace 'normed' kwarg to hist by 'density' in tests and docs. #10258

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion examples/statistics/hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
thispatch.set_facecolor(color)

# We can also normalize our inputs by the total number of counts
axs[1].hist(x, bins=n_bins, normed=True)
axs[1].hist(x, bins=n_bins, density=True)

# Now we format the y-axis to display percentage
axs[1].yaxis.set_major_formatter(PercentFormatter(xmax=1))
Expand Down
2 changes: 1 addition & 1 deletion examples/statistics/histogram_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
fig, ax = plt.subplots()

# the histogram of the data
n, bins, patches = ax.hist(x, num_bins, normed=1)
n, bins, patches = ax.hist(x, num_bins, density=True)

# add a 'best fit' line
y = mlab.normpdf(bins, mu, sigma)
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2932,7 +2932,7 @@ def test_hist_stacked_normed():
d2 = np.linspace(0, 10, 50)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.hist((d1, d2), stacked=True, normed=True)
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 this should stay as it is, because we should still be testing that normed works until it is removed.

Copy link
Member

Choose a reason for hiding this comment

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

In that case, shouldn't the test have two forms, one for 'normed' and the other for 'density'? At a more general level, we never have tested everything, and never will--there are too many possible combinations. We need to concentrate on the most useful tests, putting our resources, and those of the CI services, where they will be most effective in improving mpl. Testing that a deprecated kwarg still works seems very low priority, doesn't it? The time of deprecation seems like a perfectly reasonable time to switch a test to the non-deprecated alternative.

Copy link
Member

Choose a reason for hiding this comment

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

  • There is a test directly below this one for density.
  • Sure we've never tested everything, but we should aim to test everything. This test definitely isn't a CI bottleneck.
  • In my opinion, something being deprecated means it is still supported, but there are plans for it to be removed. If it's supported, it should be tested.

I'm not going to block on removing the normed test, but I am -2 on it.

Copy link
Member

Choose a reason for hiding this comment

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

Aiming to test everything doesn't make sense to me, for the reason stated above.

ax.hist((d1, d2), stacked=True, density=True)


@image_comparison(baseline_images=['hist_stacked_normed'], extensions=['png'])
Expand Down
3 changes: 1 addition & 2 deletions tutorials/introductory/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,7 @@ def f(t):
x = mu + sigma * np.random.randn(10000)

# the histogram of the data
n, bins, patches = plt.hist(x, 50, normed=1, facecolor='g', alpha=0.75)

n, bins, patches = plt.hist(x, 50, density=True, facecolor='g', alpha=0.75)

plt.xlabel('Smarts')
plt.ylabel('Probability')
Expand Down