Transform np creation function into blocked version
(func, *args, **kwargs)
| 82 | |
| 83 | |
| 84 | def 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…