-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_laziter.py
51 lines (40 loc) · 947 Bytes
/
test_laziter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from laziter import laziter
def test_pass():
assert True
def sq(a):
return a ** 2
negsq = (
laziter([1, 2, [3, [4, range(10000), 69]]])
.flatten()
.drop(8888)
.parmap(sq)
.parmap(lambda a: -a, mp_backend="threading", n_cpus=3)
.parmap(lambda a: a * 2, mp_backend="pathos", chunksize=16)
.filter(lambda a: a % 2 == 0)
.map(lambda a: -a)
)
def test_parmap():
next(iter(negsq))
def test_take():
assert list(negsq.take(5)) == [
157850912,
157886450,
157921992,
157957538,
157993088,
]
def test_reduce():
assert negsq.take(20).reduce(int.__add__) == 3163775020
def test_slice():
assert list(negsq[0:10]) == [
157850912,
157886450,
157921992,
157957538,
157993088,
158028642,
158064200,
158099762,
158135328,
158170898,
]