-
Notifications
You must be signed in to change notification settings - Fork 21
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
[WIP] Multidimensional bins #59
base: master
Are you sure you want to change the base?
Conversation
I've realised that this feature is kind of inconvenient to try and implement in xhistogram in its current form. xhistogram's numpy API means that all ND bins have to be passed as pure numpy arrays through Instead, IMO it would be much easier (/a better use of time) to implement this feature in xarray directly (either in pydata/xarray#5400 or in a later PR). That's because in a pure xarray implementation there would be no need to have an internal function accepting only unlabelled numpy arrays: as you always know which axis on your given bins array is which you can grab the indices from the dim labels as needed and pass them straight to I like to think that this PR will be useful as a template for the xarray implementation though. @aaronspring FYI |
For future reference this SO discussion is about whether there are clever vectorized ways to do the bincounting when the weights are >1D. |
Work-in-progress attempt to implement #28 . Builds atop #49.
_bincount_2d_vectorized
np.digitize
in a loop over the broadcast dimension using different bins (can't apply digitize directly to the whole array because it only accepts 1D bins input)However my test for checking the results of a 2D bins arrays doesn't actually pass and I haven't yet worked out why :/ It generates the right shape but the wrong counts.
(There are also a couple of other failing tests but I think they are just to do with input sanitization edge cases)
@aaronspring