MCPcopy Index your code
hub / github.com/dask/dask / Concatenate

Class Concatenate

dask/array/_array_expr/_expr.py:232–271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230
231
232class Concatenate(ArrayExpr):
233 _parameters = ["array", "axis", "meta"]
234
235 @functools.cached_property
236 def args(self):
237 return [self.array] + self.operands[len(self._parameters) :]
238
239 @functools.cached_property
240 def _meta(self):
241 return self.operand("meta")
242
243 @functools.cached_property
244 def chunks(self):
245 bds = [a.chunks for a in self.args]
246 chunks = (
247 bds[0][: self.axis]
248 + (sum((bd[self.axis] for bd in bds), ()),)
249 + bds[0][self.axis + 1 :]
250 )
251 return chunks
252
253 @functools.cached_property
254 def _name(self):
255 return f"stack-{self.deterministic_token}"
256
257 def _layer(self) -> dict:
258 axis = self.axis
259 cum_dims = [0] + list(accumulate(add, [len(a.chunks[axis]) for a in self.args]))
260 keys = list(product([self._name], *[range(len(bd)) for bd in self.chunks]))
261 names = [a.name for a in self.args]
262
263 values = [
264 (names[bisect(cum_dims, key[axis + 1]) - 1],)
265 + key[1 : axis + 1]
266 + (key[axis + 1] - cum_dims[bisect(cum_dims, key[axis + 1]) - 1],)
267 + key[axis + 2 :]
268 for key in keys
269 ]
270
271 return dict(zip(keys, values))
272
273
274class FinalizeComputeArray(FinalizeCompute, ArrayExpr):

Callers 1

concatenateFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…