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

Function from_array

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

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

Calls 12

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
getMethod · 0.45
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