xgcm / xhistogram

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

raise TypeError if `weights` is a dask array and bins are not provided as numpy arrays #77

Closed dougiesquire closed 1 year ago

dougiesquire commented 1 year ago

xhistogram uses the numpy.histogram_bin_edges function to provide options for specifying bins other than numpy arrays of bin edges. If the inputs to numpy.histogram_bin_edges are dask arrays, computation is triggered.

To account for this, xhistogram should raise a TypeError if args or weights are dask arrays and bins are not provided as numpy arrays. Prior to this PR, only args was checked.

Closes #12

codecov[bot] commented 1 year ago

Codecov Report

Merging #77 (5c1a049) into master (44a7838) will not change coverage. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master      #77   +/-   ##
=======================================
  Coverage   97.20%   97.20%           
=======================================
  Files           2        2           
  Lines         250      250           
  Branches       71       71           
=======================================
  Hits          243      243           
  Misses          5        5           
  Partials        2        2           
Impacted Files Coverage Δ
xhistogram/xarray.py 96.49% <ø> (ø)
xhistogram/core.py 97.40% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

dougiesquire commented 1 year ago

This is a pretty minor change, so I'm going to go ahead and merge this in three days if there are no objections (@TomNicholas, @rabernat)