8000 documenting dtype of hist counts by pharshalp · Pull Request #12800 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

documenting dtype of hist counts #12800

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 23, 2018
Merged

documenting dtype of hist counts #12800

merged 1 commit into from
Nov 23, 2018

Conversation

pharshalp
Copy link
Contributor
@pharshalp pharshalp commented Nov 12, 2018

PR Summary

closes #12784
Updating the documentation for hist to clarify that the dtype of values of histogram i.e. counts being returned will always be float (even when no weighting or normalization is used).

Reviewers --
(1) please let me know if the explanation for this behavior needs to be added in the documentation (since this is a "side-effect" of accommodating numpy.histogram's inconsistent behavior, I am not sure how much detail should go in the docstring).
(2) Please have a look at #12802 for an alternative solution

I am not sure which approach should be preferred.

PR Checklist

  • [ ] Has Pytest style unit tests
  • Code is Flake 8 compliant
  • [ ] New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • [ ] Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • [ ] Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@jklymak jklymak changed the title documenting dtype of hist bins #12784 documenting dtype of hist bins Nov 12, 2018
@pharshalp pharshalp changed the title documenting dtype of hist bins documenting dtype of hist counts Nov 14, 2018
Copy link
Member
@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

I'd prefer that hist has the same behavior as numpy.histogram, i.e. returning int counts for non-normed values and float for normed values.

In [20]: data = np.exp(np.linspace(0, 3, 101))

In [21]: np.histogram(data, bins=4)
Out[21]: 
(array([59, 20, 12, 10]),
 array([ 1.        ,  5.77138423, 10.54276846, 15.31415269, 20.08553692]))

In [22]: np.histogram(data, bins=4, normed=True)
Out[22]: 
(array([0.12242955, 0.04150154, 0.02490093, 0.02075077]),
 array([ 1.        ,  5.77138423, 10.54276846, 15.31415269, 20.08553692]))

However, documenting the current behavior is an incremental improvement and therefore I approve.

@jklymak jklymak merged commit 5ebe0e8 into matplotlib:master Nov 23, 2018
@QuLogic QuLogic added this to the v3.1 milestone Nov 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid decimals in Histogram Plot Python
5 participants
0