MCPcopy Index your code
hub / github.com/dask/dask / wrap_func_shape_as_first_arg

Function wrap_func_shape_as_first_arg

dask/array/wrap.py:48–81  ·  view source on GitHub ↗

Transform np creation function into blocked version

(func, *args, **kwargs)

Source from the content-addressed store, hash-verified

46
47
48def wrap_func_shape_as_first_arg(func, *args, **kwargs):
49 """
50 Transform np creation function into blocked version
51 """
52 if "shape" not in kwargs:
53 shape, args = args[0], args[1:]
54 else:
55 shape = kwargs.pop("shape")
56
57 if isinstance(shape, Array):
58 raise TypeError(
59 "Dask array input not supported. "
60 "Please use tuple, list, or a 1D numpy array instead."
61 )
62
63 parsed = _parse_wrap_args(func, args, kwargs, shape)
64 shape = parsed["shape"]
65 dtype = parsed["dtype"]
66 chunks = parsed["chunks"]
67 name = parsed["name"]
68 kwargs = parsed["kwargs"]
69 func = partial(func, dtype=dtype, **kwargs)
70
71 out_ind = dep_ind = tuple(range(len(shape)))
72 graph = core_blockwise(
73 func,
74 name,
75 out_ind,
76 ArrayChunkShapeDep(chunks),
77 dep_ind,
78 numblocks={},
79 )
80
81 return Array(graph, name, chunks, dtype=dtype, meta=kwargs.get("meta", None))
82
83
84def wrap_func_like(func, *args, **kwargs):

Callers

nothing calls this directly

Calls 5

ArrayChunkShapeDepClass · 0.90
ArrayClass · 0.90
_parse_wrap_argsFunction · 0.85
popMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…