MCPcopy
hub / github.com/dask/dask / apply_and_enforce

Function apply_and_enforce

dask/array/core.py:1028–1041  ·  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

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

Callers

nothing calls this directly

Calls 2

popMethod · 0.80
funcFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…