MCPcopy
hub / github.com/dask/dask / _layer

Method _layer

dask/array/_array_expr/_blockwise.py:150–202  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

148 )
149
150 def _layer(self):
151 arginds = [(a, i) for (a, i) in toolz.partition(2, self.args)]
152
153 numblocks = {}
154 dependencies = []
155 arrays = []
156
157 # Normalize arguments
158 argindsstr = []
159
160 for arg, ind in arginds:
161 if ind is None:
162 arg = normalize_arg(arg)
163 arg, collections = unpack_collections(arg)
164 dependencies.extend(collections)
165 else:
166 if (
167 hasattr(arg, "ndim")
168 and hasattr(ind, "__len__")
169 and arg.ndim != len(ind)
170 ):
171 raise ValueError(
172 f"Index string {ind} does not match array dimension {arg.ndim}"
173 )
174 # TODO(expr): this class is a confusing crutch to pass arguments to the
175 # graph, we should write them directly into the graph
176 if not isinstance(arg, ArrayBlockwiseDep):
177 numblocks[arg.name] = arg.numblocks
178 arrays.append(arg)
179 arg = arg.name
180 argindsstr.extend((arg, ind))
181
182 # Normalize keyword arguments
183 kwargs2 = {}
184 for k, v in self.kwargs.items():
185 v = normalize_arg(v)
186 v, collections = unpack_collections(v)
187 dependencies.extend(collections)
188 kwargs2[k] = v
189
190 # TODO(expr): Highlevelgraph :(
191 graph = core_blockwise(
192 self.func,
193 self._name,
194 self.out_ind,
195 *argindsstr,
196 numblocks=numblocks,
197 dependencies=dependencies,
198 new_axes=self.new_axes,
199 concatenate=self.concatenate,
200 **kwargs2,
201 )
202 return dict(graph)
203
204 def _lower(self):
205 if self.align_arrays:

Callers

nothing calls this directly

Calls 3

normalize_argFunction · 0.90
unpack_collectionsFunction · 0.90
itemsMethod · 0.45

Tested by

no test coverage detected