Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
v2 = flu(range(10)).map(lambda x: (x, [x]))
assert v1.collect() == v2.collect()
# Sort
gen = flu([1, 2, 1, 2]).group_by(lambda x: x, sort=False)
assert gen.count() == 4
gen = flu([1, 2, 1, 2]).group_by(lambda x: x, sort=True)
assert gen.count() == 2
# Identity Function
points = [
{'x': 1, 'y': 0},
{'x': 4, 'y': 3},
{'x': 1, 'y': 5}
]
key_func = lambda u: u['x']
gen = flu.group_by(points, key=key_func, sort=True).collect()
assert len(gen) == 2
assert gen[0][0] == 1
assert gen[1][0] == 4
assert len(gen[0][1].collect()) == 2
assert len(gen[1][1].collect()) == 1