MCPcopy Create free account
hub / github.com/dask/dask / from_array

Function from_array

dask/array/core.py:3466–3722  ·  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

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