Skip to content

Histogram update: support range, weights and density - #3124

Merged
mergify[bot] merged 7 commits into
cupy:masterfrom
grlee77:histogram_update
Mar 4, 2020
Merged

mergify[bot] merged 7 commits into
cupy:masterfrom
grlee77:histogram_update

Conversation

@grlee77

@grlee77 grlee77 commented Feb 25, 2020

Copy link
Copy Markdown
Member

Description
This PR updates the histogram function to support the range, weights and density kwargs.

It should be easiest to review the 3 commits sequentially as each of them deals with a separate kwarg.

Details
The helpers _get_outer_edges, _get_bin_edges and _ravel_and_check_weights are closely based on their NumPy implementations (except that they do not automatically convert array-likes to ndarray).

NumPy itself has a fast code path for uniform bins that loops over blocks of ~65k elements using bincount and then a second path for non-uniform bins that uses searchsorted. I have not made any changes related to those here, but left the current implementation based on ElementwiseKernel.

One question on API:
In NumPy there is also a normed argument, but its use is deprecated, so I did not add it here. My question is whether the argument should still be in the function signature and just raise a NotImplementedError if the user tries to use it?

Potential follow-ups:

  • add histogramdd (I have an implementation for this, and can make a follow-up PR)
  • add various other bin selectors to cupy.histogram. I haven't worked on this but it looks like it would be easy to add.

Comment thread cupy/statistics/histogram.py Resolved
Comment thread cupy/statistics/histogram.py Resolved
Comment thread cupy/statistics/histogram.py Resolved
grlee77 and others added 2 commits February 28, 2020 13:48
fix variable name in docstring

Co-Authored-By: emcastillo <[email protected]>
use cupy.float64 rather than float or cupy.double
use cupy.complex128 rather than complex
@emcastillo emcastillo added the cat:enhancement Improvements to existing features label Mar 3, 2020
@emcastillo emcastillo added this to the v8.0.0b1 milestone Mar 3, 2020

@emcastillo emcastillo left a comment

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.

LGTM

@emcastillo

Copy link
Copy Markdown
Member

Jenkins, test this please

@pfn-ci-bot

Copy link
Copy Markdown
Collaborator

Successfully created a job for commit 8bd4177:

@emcastillo emcastillo added the st:test-and-merge (deprecated) Ready to merge after test pass. label Mar 4, 2020
@chainer-ci

Copy link
Copy Markdown
Member

Jenkins CI test (for commit 8bd4177, target branch master) succeeded!

@mergify
mergify Bot merged commit 27123fe into cupy:master Mar 4, 2020
@grlee77
grlee77 deleted the histogram_update branch September 9, 2020 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cat:enhancement Improvements to existing features st:test-and-merge (deprecated) Ready to merge after test pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants