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

Method blocks

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

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

Callers

nothing calls this directly

Calls 1

BlockViewClass · 0.85

Tested by

no test coverage detected