Skip to content

Commit f69d79b

Browse files
shoyerXarray-Beam authors
authored andcommitted
Remove kwargs from Dataset.map_blocks.
This simplifies the signature a little bit, and allows for type checking of the applied function. PiperOrigin-RevId: 813405916
1 parent 9b51284 commit f69d79b

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

xarray_beam/_src/dataset.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -295,32 +295,27 @@ def collect_with_direct_runner(self) -> xarray.Dataset:
295295
def map_blocks(
296296
self,
297297
/,
298-
func,
298+
func: Callable[[xarray.Dataset], xarray.Dataset],
299299
*,
300-
kwargs: dict[str, Any] | None = None,
301300
template: xarray.Dataset | None = None,
302301
chunks: Mapping[str, int] | None = None,
303302
) -> Dataset:
304303
"""Map a function over the chunks of this dataset.
305304
306305
Args:
307306
func: any function that does not change the size of dataset chunks, called
308-
like `func(chunk, **kwargs)`, where `chunk` is an xarray.Dataset.
309-
kwargs: passed on to func, unmodified.
307+
like ``func(chunk)``, where ``chunk`` is an xarray.Dataset.
310308
template: new template for the resulting dataset. If not provided, an
311-
attempt will be made to infer the template by applying `func` to the
312-
existing template, which requires that `func` is implemented using dask
313-
compatible operations.
309+
attempt will be made to infer the template by applying ``func`` to the
310+
existing template, which requires that ``func`` is implemented using
311+
dask compatible operations.
314312
chunks: new chunks sizes for the resulting dataset. If not provided, an
315313
attempt will be made to infer the new chunks based on the existing
316314
chunks, dimensions sizes and the new template.
317315
318316
Returns:
319317
New Dataset with updated chunks.
320318
"""
321-
if kwargs is not None:
322-
func = functools.partial(func, **kwargs)
323-
324319
if template is None:
325320
try:
326321
template = func(self.template)

0 commit comments

Comments
 (0)