-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathexpression_test.py
More file actions
39 lines (22 loc) · 913 Bytes
/
expression_test.py
File metadata and controls
39 lines (22 loc) · 913 Bytes
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
import icepool
import pytest
from icepool import d6, map
def test_keep_highest_expression():
result = (d6.pool(4) & [1, 2, 3, 4, 5, 6] * 4).highest(3).sum()
def drop_lowest(*outcomes):
return sum(outcomes) - min(outcomes)
expected = map(drop_lowest, d6, d6, d6, d6)
assert result == expected
def test_additive_union():
assert (d6.pool(4).additive_union(d6.pool(2)[-1, -1]).sum() < 0).mean() > 0
def test_difference_keep_negative():
assert (d6.pool(4).difference(d6.pool(2), keep_negative_counts=True).sum()
< 0).mean() > 0
def test_intersection():
assert (d6.pool(4).intersection(d6.pool(2)[-1, -1]).sum() < 0).mean() > 0
def test_union():
assert (d6.pool(4)[-1, -1, -1, -1].union(d6.pool(2)[-1, -1]).sum()
< 0).mean() > 0
def test_pos():
assert (+d6.pool(2)[-1, -1]
^ +d6.pool(2)[-1, -1]).sum().probability(0) == 1