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

Method _layer

dask/array/_array_expr/_blockwise.py:150–203  ·  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 "Index string %s does not match array dimension %d"
173 % (ind, arg.ndim)
174 )
175 # TODO(expr): this class is a confusing crutch to pass arguments to the
176 # graph, we should write them directly into the graph
177 if not isinstance(arg, ArrayBlockwiseDep):
178 numblocks[arg.name] = arg.numblocks
179 arrays.append(arg)
180 arg = arg.name
181 argindsstr.extend((arg, ind))
182
183 # Normalize keyword arguments
184 kwargs2 = {}
185 for k, v in self.kwargs.items():
186 v = normalize_arg(v)
187 v, collections = unpack_collections(v)
188 dependencies.extend(collections)
189 kwargs2[k] = v
190
191 # TODO(expr): Highlevelgraph :(
192 graph = core_blockwise(
193 self.func,
194 self._name,
195 self.out_ind,
196 *argindsstr,
197 numblocks=numblocks,
198 dependencies=dependencies,
199 new_axes=self.new_axes,
200 concatenate=self.concatenate,
201 **kwargs2,
202 )
203 return dict(graph)
204
205 def _lower(self):
206 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