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

Function normalize_arg

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

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