Skip to content

Commit c7a6477

Browse files
committed
using strings in fixtures not gbt.Rational
1 parent 8e3f0f4 commit c7a6477

1 file changed

Lines changed: 52 additions & 70 deletions

File tree

tests/test_rsf.py

Lines changed: 52 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -79,99 +79,78 @@
7979
np.array(
8080
[
8181
[
82-
[
83-
Rational(1, 1),
84-
Rational(1, 1)
85-
],
86-
[
87-
Rational(4, 1),
88-
Rational(0, 1)
89-
]
82+
[Rational(1, 1), Rational(1, 1)],
83+
[Rational(4, 1), Rational(0, 1)],
9084
],
9185
[
92-
[
93-
Rational(3, 1),
94-
Rational(0, 1)
95-
],
96-
[
97-
Rational(3, 1),
98-
Rational(0, 1)
99-
]
100-
]
86+
[Rational(3, 1), Rational(0, 1)],
87+
[Rational(3, 1), Rational(0, 1)],
88+
],
10189
]
10290
),
10391
np.array(
10492
[
10593
[
106-
[
107-
Rational(1, 1),
108-
Rational(1, 1)
109-
],
110-
[
111-
Rational(4, 1),
112-
Rational(0, 1)
113-
]
94+
[Rational(1, 1), Rational(1, 1)],
95+
[Rational(4, 1), Rational(0, 1)],
11496
],
11597
[
116-
[
117-
Rational(2, 1),
118-
Rational(0, 1)
119-
],
120-
[
121-
Rational(2, 1),
122-
Rational(0, 1)
123-
]
124-
]
98+
[Rational(2, 1), Rational(0, 1)],
99+
[Rational(2, 1), Rational(0, 1)],
100+
],
125101
]
126102
),
127103
np.array(
128104
[
129105
[
130-
[
131-
Rational(1, 1),
132-
Rational(1, 1)
133-
],
134-
[
135-
Rational(0, 1),
136-
Rational(1, 1)
137-
]
106+
[Rational(1, 1), Rational(1, 1)],
107+
[Rational(0, 1), Rational(1, 1)],
138108
],
139109
[
140-
[
141-
Rational(2, 1),
142-
Rational(0, 1)
143-
],
144-
[
145-
Rational(2, 1),
146-
Rational(0, 1)
147-
]
148-
]
110+
[Rational(2, 1), Rational(0, 1)],
111+
[Rational(2, 1), Rational(0, 1)],
112+
],
149113
]
150-
)
114+
),
151115
],
152116
),
153117
# Myerson 2-card poker; game with chance node
154118
(
155-
games.read_from_file("myerson_2_card_poker.efg"),
119+
games.read_from_file("myerson_2_card_poker.efg"), # CHANGE
156120
[["11", "12", "21", "22"], ["1", "2"]],
157121
[
158-
np.array(
159-
[
160-
[Rational(-1, 1), Rational(0, 1)],
161-
[Rational(-1, 2), Rational(-1, 1)],
162-
[Rational(-5, 2), Rational(-1, 1)],
163-
[Rational(-2, 1), Rational(-2, 1)]
164-
]
165-
),
166-
np.array(
167-
[
168-
[Rational(1, 1), Rational(0, 1)],
169-
[Rational(1, 2), Rational(1, 1)],
170-
[Rational(5, 2), Rational(1, 1)],
171-
[Rational(2, 1), Rational(2, 1)]]
172-
)
122+
np.array([["-1", "0"], ["-1/2", "-1"], ["-5/2", "-1"], ["-2", "-2"]]),
123+
np.array([["1", "0"], ["1/2", "1"], ["5/2", "1"], ["2", "2"]]),
173124
],
174-
)
125+
),
126+
# 2-player (zero-sum) game with reduction for both players and generic payoffs
127+
# (
128+
# games.create_reduction_generic_payoffs_efg(),
129+
# [["11*", "12*", "211", "221", "212", "222"],
130+
# ["1*1", "1*2", "2**", "31*", "32*", "4**"] ],
131+
# [
132+
# np.array(
133+
# [
134+
# ["1", "2", "3", "4", "5", "6"],
135+
# ["1", "2", "3", "4", "5", "6"],
136+
# ["1", "2", "3", "4", "5", "6"],
137+
# ["1", "2", "3", "4", "5", "6"],
138+
# ["1", "2", "3", "4", "5", "6"],
139+
# ["1", "2", "3", "4", "5", "6"],
140+
# ]
141+
# ),
142+
# np.array(
143+
# [
144+
# ["1", "2", "3", "4", "5", "6"],
145+
# ["1", "2", "3", "4", "5", "6"],
146+
# ["1", "2", "3", "4", "5", "6"],
147+
# ["1", "2", "3", "4", "5", "6"],
148+
# ["1", "2", "3", "4", "5", "6"],
149+
# ["1", "2", "3", "4", "5", "6"],
150+
# ]
151+
# )
152+
# ],
153+
# ),
175154
],
176155
)
177156
def test_reduced_strategic_form(
@@ -184,6 +163,9 @@ def test_reduced_strategic_form(
184163
- that the payoff tables are correct, which is done via game.to_arrays()
185164
"""
186165
arrays = game.to_arrays()
166+
187167
for i, player in enumerate(game.players):
188168
assert strategy_labels[i] == [s.label for s in player.strategies]
189-
assert (arrays[i] == np_arrays_of_rsf[i]).all()
169+
# convert strings to rationals
170+
exp_array = arrays[i].astype(gbt.Rational)
171+
assert (arrays[i] == exp_array).all()

0 commit comments

Comments
 (0)