MCPcopy
hub / github.com/dask/dask / from_array

Function from_array

dask/array/core.py:3468–3724  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

3466
3467
3468def 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

Calls 11

is_dask_collectionFunction · 0.90
is_arraylikeFunction · 0.90
SerializableLockClass · 0.90
allFunction · 0.90
normalize_chunksFunction · 0.85
slices_from_chunksFunction · 0.85
graph_from_arraylikeFunction · 0.85
splitMethod · 0.80
ArrayClass · 0.70
tokenizeFunction · 0.50
copyMethod · 0.45

Tested by 15

test_concatenate_typesFunction · 0.72
test_elemwise_on_scalarsFunction · 0.72
test_operatorsFunction · 0.72
test_field_accessFunction · 0.72
test_matmulFunction · 0.72
test_matmul_array_ufuncFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…