| 842 | |
| 843 | @derived_from(np) |
| 844 | def fromfunction(func, chunks="auto", shape=None, dtype=None, **kwargs): |
| 845 | dtype = dtype or float |
| 846 | chunks = normalize_chunks(chunks, shape, dtype=dtype) |
| 847 | |
| 848 | inds = tuple(range(len(shape))) |
| 849 | |
| 850 | arrs = [arange(s, dtype=dtype, chunks=c) for s, c in zip(shape, chunks)] |
| 851 | arrs = meshgrid(*arrs, indexing="ij") |
| 852 | |
| 853 | args = sum(zip(arrs, itertools.repeat(inds)), ()) |
| 854 | |
| 855 | res = blockwise(func, inds, *args, token="fromfunction", **kwargs) |
| 856 | |
| 857 | return res |
| 858 | |
| 859 | |
| 860 | @derived_from(np) |