MCPcopy
hub / github.com/dask/dask / normalize_arg

Function normalize_arg

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

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…