xgcm / xhistogram

Fast, flexible, label-aware histograms for numpy and xarray
https://xhistogram.readthedocs.io
MIT License
89 stars 19 forks source link

Refactor to use searchsorted instead of digitize #43

Closed dougiesquire closed 3 years ago

dougiesquire commented 3 years ago

numpy uses searchsorted to compute the bin number each sample falls into (see here). xhistogram currently use digitize (see here).

Refactoring to use searchsorted would come with performance improvements and would simplify how we align our bin definitions with numpy, potentially also solving #25.

dougiesquire commented 3 years ago

I've just realised that since numpy 1.10.0 np.digitize is actually implemented using np.searchsorted (https://github.com/numpy/numpy/pull/5101)