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

Class Stack

dask/array/_array_expr/_expr.py:184–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182
183
184class Stack(ArrayExpr):
185 _parameters = ["array", "axis", "meta"]
186
187 @functools.cached_property
188 def args(self):
189 return [self.array] + self.operands[len(self._parameters) :]
190
191 @functools.cached_property
192 def _meta(self):
193 return self.operand("meta")
194
195 @functools.cached_property
196 def chunks(self):
197 n = len(self.args)
198 return (
199 self.array.chunks[: self.axis]
200 + ((1,) * n,)
201 + self.array.chunks[self.axis :]
202 )
203
204 @functools.cached_property
205 def _name(self):
206 return f"stack-{self.deterministic_token}"
207
208 def _layer(self) -> dict:
209 keys = list(product([self._name], *[range(len(bd)) for bd in self.chunks]))
210 names = [a.name for a in self.args]
211 axis = self.axis
212 ndim = self._meta.ndim - 1
213
214 inputs = [
215 (names[key[axis + 1]],) + key[1 : axis + 1] + key[axis + 2 :]
216 for key in keys
217 ]
218 values = [
219 Task(
220 key,
221 getitem,
222 TaskRef(inp),
223 (slice(None, None, None),) * axis
224 + (None,)
225 + (slice(None, None, None),) * (ndim - axis),
226 )
227 for key, inp in zip(keys, inputs)
228 ]
229 return dict(zip(keys, values))
230
231
232class Concatenate(ArrayExpr):

Callers 1

stackFunction · 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…