EFR code issue with NumPy
lanctot opened this issue · 4 comments
lanctot commented
CI tests are failing on the EFR code: https://github.com/google-deepmind/open_spiel/actions/runs/10438874702/job/28948184064
Here is the problem:
EFRTest.test_efr_kuhn_poker4 ('csps')
test_efr_kuhn_poker('csps')
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/tmp.qKWdCXq1hQ/venv/lib/python3.10/site-packages/absl/testing/parameterized.py", line 323, in bound_param_test
return test_method(self, testcase_params)
File "/project/open_spiel/python/algorithms/efr_test.py", line 69, in test_efr_kuhn_poker
efr_solver = efr.EFRSolver(
File "/tmp/tmp.qKWdCXq1hQ/venv/lib/python3.10/site-packages/open_spiel/python/algorithms/efr.py", line 497, in __init__
super(EFRSolver, self).__init__(game, deviation_sets)
File "/tmp/tmp.qKWdCXq1hQ/venv/lib/python3.10/site-packages/open_spiel/python/algorithms/efr.py", line 117, in __init__
self._initialize_info_state_nodes(self._root_node, hist, empty_path_indices)
File "/tmp/tmp.qKWdCXq1hQ/venv/lib/python3.10/site-packages/open_spiel/python/algorithms/efr.py", line 188, in _initialize_info_state_nodes
self._initialize_info_state_nodes(
File "/tmp/tmp.qKWdCXq1hQ/venv/lib/python3.10/site-packages/open_spiel/python/algorithms/efr.py", line 188, in _initialize_info_state_nodes
self._initialize_info_state_nodes(
File "/tmp/tmp.qKWdCXq1hQ/venv/lib/python3.10/site-packages/open_spiel/python/algorithms/efr.py", line 212, in _initialize_info_state_nodes
info_state_node.relizable_deviations = self._deviation_gen(
File "/tmp/tmp.qKWdCXq1hQ/venv/lib/python3.10/site-packages/open_spiel/python/algorithms/efr.py", line 818, in return_cs_partial_sequence
external = return_all_external_modified_deviations(
File "/tmp/tmp.qKWdCXq1hQ/venv/lib/python3.10/site-packages/open_spiel/python/algorithms/efr.py", line 1236, in return_all_external_modified_deviations
modification_index = np.where(prior_actions_weight == 0)[0][0]
ValueError: Calling nonzero on 0d arrays is not allowed. Use np.atleast_1d(scalar).nonzero() instead. If the context of this error is of the form `arr[nonzero(cond)]`, just use `arr[cond]`.
lanctot commented
@Jamesflynn1 can you take a look?
lanctot commented
Specifically, lines 1137 and 1236 of efr.py.
NumPy seems to sometimes have an issue with this line modification_index = np.where(prior_actions_weight == 0)[0][0]
. Is there a different way to write that might be more compatible across numpy/python versions?
Jamesflynn1 commented
Hi @lanctot, I took a look at the offending coding and the aim of it was to find the index of the first zero of the prior_actions_weight array. There definitely should be a cleaner and more compatible way to do that in NumPy and I will take a look at that now.