MCPcopy
hub / github.com/dask/dask / slice_array

Function slice_array

dask/array/slicing.py:101–175  ·  view source on GitHub ↗

Main function for array slicing This function makes a new dask that slices blocks along every dimension and aggregates (via cartesian product) each dimension's slices so that the resulting block slices give the same results as the original slice on the original structure I

(out_name, in_name, blockdims, index)

Source from the content-addressed store, hash-verified

99
100@disable_gc()
101def slice_array(out_name, in_name, blockdims, index):
102 """
103 Main function for array slicing
104
105 This function makes a new dask that slices blocks along every
106 dimension and aggregates (via cartesian product) each dimension's
107 slices so that the resulting block slices give the same results
108 as the original slice on the original structure
109
110 Index must be a tuple. It may contain the following types
111
112 int, slice, list (at most one list), None
113
114 Parameters
115 ----------
116 in_name - string
117 This is the dask variable name that will be used as input
118 out_name - string
119 This is the dask variable output name
120 blockshape - iterable of integers
121 index - iterable of integers, slices, lists, or None
122
123 Returns
124 -------
125 Dict where the keys are tuples of
126
127 (out_name, dim_index[, dim_index[, ...]])
128
129 and the values are
130
131 (function, (in_name, dim_index, dim_index, ...),
132 (slice(...), [slice()[,...]])
133
134 Also new blockdims with shapes of each block
135
136 ((10, 10, 10, 10), (20, 20))
137
138 Examples
139 --------
140 >>> from pprint import pprint
141 >>> dsk, blockdims = slice_array('y', 'x', [(20, 20, 20, 20, 20)],
142 ... (slice(10, 35),))
143 >>> pprint(dsk) # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
144 {('y', 0): <Task ('y', 0) getitem(TaskRef(('x', 0)), (slice(10, 20, 1),))>,
145 ('y', 1): <Task ('y', 1) getitem(TaskRef(('x', 1)), (slice(0, 15, 1),))>}
146 >>> blockdims
147 ((10, 15),)
148
149 See Also
150 --------
151 This function works by successively unwrapping cases and passing down
152 through a sequence of functions.
153
154 slice_with_newaxis : handle None/newaxis case
155 slice_wrap_lists : handle fancy indexing with lists
156 slice_slices_and_integers : handle everything else
157 """
158 blockdims = tuple(map(tuple, blockdims))

Callers 1

__getitem__Method · 0.90

Calls 4

allFunction · 0.85
SlicingNoopClass · 0.85
sumFunction · 0.70
slice_with_newaxesFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…