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