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",
name=None,
lock=False,
asarray=None,
fancy=True,
getitem=None,
meta=None,
inline_array=False,
)
| 3466 | |
| 3467 | |
| 3468 | def from_array( |
| 3469 | x, |
| 3470 | chunks="auto", |
| 3471 | name=None, |
| 3472 | lock=False, |
| 3473 | asarray=None, |
| 3474 | fancy=True, |
| 3475 | getitem=None, |
| 3476 | meta=None, |
| 3477 | inline_array=False, |
| 3478 | ): |
| 3479 | """Create dask array from something that looks like an array. |
| 3480 | |
| 3481 | Input must have a ``.shape``, ``.ndim``, ``.dtype`` and support numpy-style slicing. |
| 3482 | |
| 3483 | Parameters |
| 3484 | ---------- |
| 3485 | x : array_like |
| 3486 | chunks : int, tuple |
| 3487 | How to chunk the array. Must be one of the following forms: |
| 3488 | |
| 3489 | - A blocksize like 1000. |
| 3490 | - A blockshape like (1000, 1000). |
| 3491 | - Explicit sizes of all blocks along all dimensions like |
| 3492 | ((1000, 1000, 500), (400, 400)). |
| 3493 | - A size in bytes, like "100 MiB" which will choose a uniform |
| 3494 | block-like shape |
| 3495 | - The word "auto" which acts like the above, but uses a configuration |
| 3496 | value ``array.chunk-size`` for the chunk size |
| 3497 | |
| 3498 | -1 or None as a blocksize indicate the size of the corresponding |
| 3499 | dimension. |
| 3500 | name : str or bool, optional |
| 3501 | The key name to use for the array. Defaults to a hash of ``x``. |
| 3502 | |
| 3503 | Hashing is useful if the same value of ``x`` is used to create multiple |
| 3504 | arrays, as Dask can then recognise that they're the same and |
| 3505 | avoid duplicate computations. However, it can also be slow, and if the |
| 3506 | array is not contiguous it is copied for hashing. If the array uses |
| 3507 | stride tricks (such as :func:`numpy.broadcast_to` or |
| 3508 | :func:`skimage.util.view_as_windows`) to have a larger logical |
| 3509 | than physical size, this copy can cause excessive memory usage. |
| 3510 | |
| 3511 | If you don't need the deduplication provided by hashing, use |
| 3512 | ``name=False`` to generate a random name instead of hashing, which |
| 3513 | avoids the pitfalls described above. Using ``name=True`` is |
| 3514 | equivalent to the default. |
| 3515 | |
| 3516 | By default, hashing uses python's standard sha1. This behaviour can be |
| 3517 | changed by installing cityhash, xxhash or murmurhash. If installed, |
| 3518 | a large-factor speedup can be obtained in the tokenisation step. |
| 3519 | |
| 3520 | .. note:: |
| 3521 | |
| 3522 | Because this ``name`` is used as the key in task graphs, you should |
| 3523 | ensure that it uniquely identifies the data contained within. If |
| 3524 | you'd like to provide a descriptive name that is still unique, combine |
| 3525 | the descriptive name with :func:`dask.base.tokenize` of the |
searching dependent graphs…