Skip to content

Adding density hist2d #12563

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 10 commits into from
Closed

Conversation

thoo
Copy link
Contributor

@thoo thoo commented Oct 19, 2018

Close #11070

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.

Note also that you do not have to open a new PR if you are not satisfied with your commits so far. You can always force-push to modify existing commits. This keeps the tracker a bit cleaner.

"simultaneously. Please only use 'density', "
"since 'normed' is deprecated.")
if normed is not None:
cbook.warn_deprecated("2.1", name="'normed'", obj_type="kwarg",
Copy link
Member

Choose a reason for hiding this comment

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

You cannot deprecate for "2.1". The deprecation has to be always for the next point release, i.e. currently "3.1". removal can be omitted. That's two minor point releases by default.

normed : bool, optional, default: False
Normalize histogram.
density : boolean, optional
If False, the default, returns the number of samples in each bin.
Copy link
Member

Choose a reason for hiding this comment

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

"returns" is a bit misleading. I would use "plots and returns".

@thoo thoo force-pushed the adding_density_hist2d branch from b2daa26 to d063002 Compare October 20, 2018 14:46
@thoo
Copy link
Contributor Author

thoo commented Oct 20, 2018

@timhoffm Thanks for the comments. I was getting hard time rebasing. Last time I rebased my branch, I got other people commits on my branch and I just rebase this branch now and it looks fine after following this. So git push -f is okay if I am the only person on that branch??? I usually get a diverged message after rebase.

@jklymak jklymak changed the title Adding density hist2d #11070 Adding density hist2d Oct 20, 2018
Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Please be sure to add tests that test the new kwarg, and that test the Error.

If False, the default, plots and returns the number of samples
in each bin. If True, returns the probability *density*
function at the bin, ``bin_count / sample_count / bin_area``.
Default is ``None`` for both *normed* and *density*. If either is
Copy link
Member

Choose a reason for hiding this comment

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

Can we keep the discussion of deprecated normed kwarg in the description of that kwarg?

cbook.warn_deprecated("3.1", name="'normed'", obj_type="kwarg",
alternative="'density")

normed = bool(density) or bool(normed)
h, xedges, yedges = np.histogram2d(x, y, bins=bins, range=range,
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should call the argument normed if we are going to change to density later.

This could also use a comment in here about how we will need to switch to density when np1.15 becomes our minimal version. Otherwise if I was looking at this code I'd have no idea why you are deprecating the name normed when that's what numpy is using. Indeed reviewing this I had to see @anntzer 's comment: #11070 (comment) to understand why you were doing this. Should probably be in the PR description as well to save folks back referencing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comments. I was trying to be consistent with hist. #11070 was opened to have API consistency. I can also change hist to be consistent with your suggestions.

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with the change proposed here , but only because numpy is moving to using density as well (in np1.15). So the PR should be clear why we are doing this.

Copy link
Member

Choose a reason for hiding this comment

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

So you still have normed = bool(density) or bool(normed), I think you should be populating and using density not normed.

I think there should be a comment in the code here for future reference to explain this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I misunderstood about your comment on density. Let me fix it right away.

@thoo thoo force-pushed the adding_density_hist2d branch 2 times, most recently from 653be4e to 14a74ac Compare October 21, 2018 07:15
@@ -6869,8 +6878,20 @@ def hist2d(self, x, y, bins=10, range=None, normed=False, weights=None,
keyword argument. Likewise, power-law normalization (similar
in effect to gamma correction) can be accomplished with
`.colors.PowerNorm`.
- Numpy 1.15 introduced a 'density' kwarg to ``hist2d``. Even though
Numpy 1.15 isn't required, 'density' kwarg is introduced
and passed as 'normed' to ``hist2d``.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jklymak Do you want me to place this explanation somewhere else? Thanks.

Copy link
Member

Choose a reason for hiding this comment

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

This probably doesn’t hurt I might have put it in the normed kwarg description

@thoo thoo force-pushed the adding_density_hist2d branch from efb6cb2 to ab1765d Compare October 25, 2018 04:28
@jklymak
Copy link
Member

jklymak commented Oct 26, 2018

@thoo please ping me when this is ready and ask for a re-review!

@thoo
Copy link
Contributor Author

thoo commented Oct 27, 2018

@jklymak Can you re-review this PR?

@anntzer anntzer mentioned this pull request Jan 7, 2019
6 tasks
@anntzer
Copy link
Contributor

anntzer commented Mar 19, 2019

This was covered by #13128.
Thanks for the PR, hoping to see you around again :)

@anntzer anntzer closed this Mar 19, 2019
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.

4 participants