MCPcopy Create free account
hub / github.com/dask/dask / apply_and_enforce

Function apply_and_enforce

dask/array/core.py:1023–1036  ·  view source on GitHub ↗

Apply a function, and enforce the output.ndim to match expected_ndim Ensures the output has the expected dimensionality.

(*args, **kwargs)

Source from the content-addressed store, hash-verified

1021
1022
1023def apply_and_enforce(*args, **kwargs):
1024 """Apply a function, and enforce the output.ndim to match expected_ndim
1025
1026 Ensures the output has the expected dimensionality."""
1027 func = kwargs.pop("_func")
1028 expected_ndim = kwargs.pop("expected_ndim")
1029 out = func(*args, **kwargs)
1030 if getattr(out, "ndim", 0) != expected_ndim:
1031 out_ndim = getattr(out, "ndim", 0)
1032 raise ValueError(
1033 f"Dimension mismatch: expected output of {func} "
1034 f"to have dims = {expected_ndim}. Got {out_ndim} instead."
1035 )
1036 return out
1037
1038
1039def broadcast_chunks(*chunkss):

Callers

nothing calls this directly

Calls 2

popMethod · 0.80
funcFunction · 0.70

Tested by

no test coverage detected