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

Method blocks

dask/array/core.py:2098–2135  ·  view source on GitHub ↗

An array-like interface to the blocks of an array. This returns a ``Blockview`` object that provides an array-like interface to the blocks of a dask array. Numpy-style indexing of a ``Blockview`` object returns a selection of blocks as a new dask array. You can ind

(self)

Source from the content-addressed store, hash-verified

2096
2097 @property
2098 def blocks(self):
2099 """An array-like interface to the blocks of an array.
2100
2101 This returns a ``Blockview`` object that provides an array-like interface
2102 to the blocks of a dask array. Numpy-style indexing of a ``Blockview`` object
2103 returns a selection of blocks as a new dask array.
2104
2105 You can index ``array.blocks`` like a numpy array of shape
2106 equal to the number of blocks in each dimension, (available as
2107 array.blocks.size). The dimensionality of the output array matches
2108 the dimension of this array, even if integer indices are passed.
2109 Slicing with ``np.newaxis`` or multiple lists is not supported.
2110
2111 Examples
2112 --------
2113 >>> import dask.array as da
2114 >>> x = da.arange(8, chunks=2)
2115 >>> x.blocks.shape # aliases x.numblocks
2116 (4,)
2117 >>> x.blocks[0].compute()
2118 array([0, 1])
2119 >>> x.blocks[:3].compute()
2120 array([0, 1, 2, 3, 4, 5])
2121 >>> x.blocks[::2].compute()
2122 array([0, 1, 4, 5])
2123 >>> x.blocks[[-1, 0]].compute()
2124 array([6, 7, 0, 1])
2125 >>> x.blocks.ravel() # doctest: +NORMALIZE_WHITESPACE
2126 [dask.array<blocks, shape=(2,), dtype=int64, chunksize=(2,), chunktype=numpy.ndarray>,
2127 dask.array<blocks, shape=(2,), dtype=int64, chunksize=(2,), chunktype=numpy.ndarray>,
2128 dask.array<blocks, shape=(2,), dtype=int64, chunksize=(2,), chunktype=numpy.ndarray>,
2129 dask.array<blocks, shape=(2,), dtype=int64, chunksize=(2,), chunktype=numpy.ndarray>]
2130
2131 Returns
2132 -------
2133 An instance of ``dask.array.Blockview``
2134 """
2135 return BlockView(self)
2136
2137 @property
2138 def partitions(self):

Callers

nothing calls this directly

Calls 1

BlockViewClass · 0.85

Tested by

no test coverage detected