Skip to content

Commit 56e904d

Browse files
committed
adding support for other type of action_list in DiscreteActSpace [skip ci]
1 parent 8e01464 commit 56e904d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

grid2op/Converter/IdToAct.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,16 @@ def init_converter(self, all_actions=None, **kwargs):
274274
"grid2op action. The error was:\n{}".format(e)
275275
) from exc_
276276
else:
277-
raise RuntimeError("Impossible to load the action provided.")
277+
# first make sure that all action is "correct"
278+
try:
279+
nb = len(all_actions) # assert I can compute the "len"
280+
for i in range(nb):
281+
act = all_actions[i] # assert I can use the `[]` operator
282+
assert isinstance(act, BaseAction) # assert what's in there is a BaseAction
283+
except Exception as exc_:
284+
raise RuntimeError("Impossible to load the action provided.") from exc_
285+
# does not copy here (to save memory in case of shared memory setting)
286+
self.all_actions = all_actions
278287
self.n = len(self.all_actions)
279288

280289
def filter_action(self, filtering_fun):

0 commit comments

Comments
 (0)