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

Function wrap_func_like

dask/array/wrap.py:84–109  ·  view source on GitHub ↗

Transform np creation function into blocked version

(func, *args, **kwargs)

Source from the content-addressed store, hash-verified

82
83
84def wrap_func_like(func, *args, **kwargs):
85 """
86 Transform np creation function into blocked version
87 """
88 x = args[0]
89 meta = meta_from_array(x)
90 shape = kwargs.get("shape", x.shape)
91
92 parsed = _parse_wrap_args(func, args, kwargs, shape)
93 shape = parsed["shape"]
94 dtype = parsed["dtype"]
95 chunks = parsed["chunks"]
96 name = parsed["name"]
97 kwargs = parsed["kwargs"]
98
99 keys = product([name], *[range(len(bd)) for bd in chunks])
100 shapes = product(*chunks)
101 shapes = list(shapes)
102 kw = [kwargs for _ in shapes]
103 for i, s in enumerate(list(shapes)):
104 kw[i]["shape"] = s
105 vals = ((partial(func, dtype=dtype, **k),) + args for (k, s) in zip(kw, shapes))
106
107 dsk = dict(zip(keys, vals))
108
109 return Array(dsk, name, chunks, meta=meta.astype(dtype))
110
111
112@curry

Callers

nothing calls this directly

Calls 5

meta_from_arrayFunction · 0.90
ArrayClass · 0.90
_parse_wrap_argsFunction · 0.85
getMethod · 0.45
astypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…