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

Function deepmap

dask/utils.py:272–286  ·  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

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