MCPcopy
hub / github.com/dask/dask / deepmap

Function deepmap

dask/utils.py:273–287  ·  view source on GitHub ↗

Apply function inside nested lists >>> inc = lambda x: x + 1 >>> deepmap(inc, [[1, 2], [3, 4]]) [[2, 3], [4, 5]] >>> add = lambda x, y: x + y >>> deepmap(add, [[1, 2], [3, 4]], [[10, 20], [30, 40]]) [[11, 22], [33, 44]]

(func, *seqs)

Source from the content-addressed store, hash-verified

271
272
273def deepmap(func, *seqs):
274 """Apply function inside nested lists
275
276 >>> inc = lambda x: x + 1
277 >>> deepmap(inc, [[1, 2], [3, 4]])
278 [[2, 3], [4, 5]]
279
280 >>> add = lambda x, y: x + y
281 >>> deepmap(add, [[1, 2], [3, 4]], [[10, 20], [30, 40]])
282 [[11, 22], [33, 44]]
283 """
284 if isinstance(seqs[0], (list, Iterator)):
285 return [deepmap(func, *items) for items in zip(*seqs)]
286 else:
287 return func(*seqs)
288
289
290@_deprecated()

Callers 4

mean_combineFunction · 0.90
mean_aggFunction · 0.90
moment_combineFunction · 0.90
moment_aggFunction · 0.90

Calls 1

funcFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…