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

Function from_array

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

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