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