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

Function normalize_arg

dask/array/core.py:516–535  ·  view source on GitHub ↗

Normalize user provided arguments to blockwise or map_blocks We do a few things: 1. If they are string literals that might collide with blockwise_token then we quote them 2. IF they are large (as defined by sizeof) then we put them into the graph on their own by using

(x)

Source from the content-addressed store, hash-verified

514
515
516def normalize_arg(x):
517 """Normalize user provided arguments to blockwise or map_blocks
518
519 We do a few things:
520
521 1. If they are string literals that might collide with blockwise_token then we
522 quote them
523 2. IF they are large (as defined by sizeof) then we put them into the
524 graph on their own by using dask.delayed
525 """
526 if is_dask_collection(x):
527 return x
528 elif isinstance(x, str) and re.match(r"_\d+", x):
529 return delayed(x)
530 elif isinstance(x, list) and len(x) >= 10:
531 return delayed(x)
532 elif sizeof(x) > 1e6:
533 return delayed(x)
534 else:
535 return x
536
537
538def _pass_extra_kwargs(func, keys, *args, **kwargs):

Callers 2

blockwiseFunction · 0.90
_layerMethod · 0.90

Calls 3

is_dask_collectionFunction · 0.90
delayedFunction · 0.90
matchMethod · 0.80

Tested by

no test coverage detected