flox icon indicating copy to clipboard operation
flox copied to clipboard

Unable to assign flox method and quantile method in xarray_reduce

Open lassiterdc opened this issue 1 year ago • 2 comments

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'

lassiterdc avatar Mar 14 '24 16:03 lassiterdc

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

dcherian avatar Mar 14 '24 17:03 dcherian

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.

lassiterdc avatar Mar 14 '24 17:03 lassiterdc