xarray-contrib / flox

Fast & furious GroupBy operations for dask.array
https://flox.readthedocs.io
Apache License 2.0
123 stars 16 forks source link

Unable to assign flox method and quantile method in xarray_reduce #340

Open lassiterdc opened 6 months ago

lassiterdc commented 6 months ago

Reproducible example:

import xarray as xr
from flox.xarray import xarray_reduce

labels = xr.DataArray(
    [1, 2, 3, 1, 2, 3, 0, 0, 0],
    dims="x",
    name="label",
)

finalize_kwargs = dict(q=[0.1,0.5,0.9], method = "hazen")

da = xr.ones_like(labels)
xarray_reduce(da, labels, func="quantile", method = "blockwise", **finalize_kwargs)

Output:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: flox.xarray.xarray_reduce() got multiple values for keyword argument 'method'
dcherian commented 6 months ago

Sigh, nice find. I should probably just allow finalize_kwargs or rename method to strategy.

Either way only method="linear" has been implemented yet. Are you interested in fixing that?

https://github.com/xarray-contrib/flox/blob/b0cabf3dc5beb0d3429bc1e7dbe08a7479beb7cb/flox/aggregate_flox.py#L109-L110

lassiterdc commented 6 months ago

I'm not sure I have the chops to do that. Using the default method="linear" is fine for me at the moment but I thought it'd be helpful to point out this issue either way.