hippalectryon-0 / xr-scipy

scipy for xarray eco-system
http://xr-scipy.readthedocs.io
60 stars 10 forks source link

apply_kwargs should be unpacked? #40

Open allen-adastra opened 6 months ago

allen-adastra commented 6 months ago

Hello,

I'm working with dask, and I stumbled across the need to specify the dask="parallelized" argument to xr.apply_ufunc in frequency_filter. Currently, there is no way to do that.

One way to do it is to unpack apply_kwargs. I'm curious what the intent of that variable is.

Before:

            ret = xr.apply_ufunc(
                sosfiltfilt,
                sos,
                darray,
                input_core_dims=[[], [dim]],
                output_core_dims=[[dim]],
                kwargs=apply_kwargs,
            )

After:

            ret = xr.apply_ufunc(
                sosfiltfilt,
                sos,
                darray,
                input_core_dims=[[], [dim]],
                output_core_dims=[[dim]],
                **apply_kwargs,
            )
hippalectryon-0 commented 1 month ago

It's all written in https://docs.xarray.dev/en/stable/generated/xarray.apply_ufunc.html :P The kwargs are forwarded to the kwargs of the function being applied.

For the dask issue, feel free to open a PR !