Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Extend `dask.compute` to work on nested data structures.
from toolz import concat
from dask import compute
def _flatten_compute(vals):
if isinstance(vals, list):
inner = list(concat(map(_flatten_compute, vals)))
return ['list', len(inner)] + inner
elif isinstance(vals, dict):
inner = []
local function groupby(func, seq)
local t = {}
for _, val in ipairs(seq) do
local key = func(val)
t[key] = t[key] or {}
t[key][#t[key] + 1] = val
end
return t
end