Create dask array from something that looks like an array. Input must have a ``.shape``, ``.ndim``, ``.dtype`` and support numpy-style slicing. Parameters ---------- x : array_like chunks : int, tuple How to chunk the array. Must be one of the following forms:
(
x,
chunks="auto",
lock=False,
asarray=None,
fancy=True,
getitem=None,
meta=None,
inline_array=False,
name=None,
)
| 1003 | |
| 1004 | |
| 1005 | def from_array( |
| 1006 | x, |
| 1007 | chunks="auto", |
| 1008 | lock=False, |
| 1009 | asarray=None, |
| 1010 | fancy=True, |
| 1011 | getitem=None, |
| 1012 | meta=None, |
| 1013 | inline_array=False, |
| 1014 | name=None, |
| 1015 | ): |
| 1016 | """Create dask array from something that looks like an array. |
| 1017 | |
| 1018 | Input must have a ``.shape``, ``.ndim``, ``.dtype`` and support numpy-style slicing. |
| 1019 | |
| 1020 | Parameters |
| 1021 | ---------- |
| 1022 | x : array_like |
| 1023 | chunks : int, tuple |
| 1024 | How to chunk the array. Must be one of the following forms: |
| 1025 | |
| 1026 | - A blocksize like 1000. |
| 1027 | - A blockshape like (1000, 1000). |
| 1028 | - Explicit sizes of all blocks along all dimensions like |
| 1029 | ((1000, 1000, 500), (400, 400)). |
| 1030 | - A size in bytes, like "100 MiB" which will choose a uniform |
| 1031 | block-like shape |
| 1032 | - The word "auto" which acts like the above, but uses a configuration |
| 1033 | value ``array.chunk-size`` for the chunk size |
| 1034 | |
| 1035 | -1 or None as a blocksize indicate the size of the corresponding |
| 1036 | dimension. |
| 1037 | name : str or bool, optional |
| 1038 | The key name to use for the array. Defaults to a hash of ``x``. |
| 1039 | |
| 1040 | Hashing is useful if the same value of ``x`` is used to create multiple |
| 1041 | arrays, as Dask can then recognise that they're the same and |
| 1042 | avoid duplicate computations. However, it can also be slow, and if the |
| 1043 | array is not contiguous it is copied for hashing. If the array uses |
| 1044 | stride tricks (such as :func:`numpy.broadcast_to` or |
| 1045 | :func:`skimage.util.view_as_windows`) to have a larger logical |
| 1046 | than physical size, this copy can cause excessive memory usage. |
| 1047 | |
| 1048 | If you don't need the deduplication provided by hashing, use |
| 1049 | ``name=False`` to generate a random name instead of hashing, which |
| 1050 | avoids the pitfalls described above. Using ``name=True`` is |
| 1051 | equivalent to the default. |
| 1052 | |
| 1053 | By default, hashing uses python's standard sha1. This behaviour can be |
| 1054 | changed by installing cityhash, xxhash or murmurhash. If installed, |
| 1055 | a large-factor speedup can be obtained in the tokenisation step. |
| 1056 | |
| 1057 | .. note:: |
| 1058 | |
| 1059 | Because this ``name`` is used as the key in task graphs, you should |
| 1060 | ensure that it uniquely identifies the data contained within. If |
| 1061 | you'd like to provide a descriptive name that is still unique, combine |
| 1062 | the descriptive name with :func:`dask.base.tokenize` of the |
searching dependent graphs…