-
Notifications
You must be signed in to change notification settings - Fork 724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Action Type Check in Env [feature request] #707
Comments
Hello, Do you have a minimal example (minimal custom env) where that error happens? It seems that you are using custom action generation (i.e. not using But I agree we can add a check in the |
It happens when I pass a single action, without wrapping it in a list. CartPole example where the possible actions are LEFT or RIGHT (one var) is an example. OK for isinstance() method if list & np.ndarray are the only 2 iterables that are acceptable. However, I'm not sure on how to check for 'that it corresponds to the number of environments'? |
I guess that's just sth like if len(self.actions) != len(self.envs):
raise ValueError("The number of actions needs to be equal to the number of environments in a VecEnv") |
This works but we need to make an exception for the |
Describe the bug
TypeError: 'int' object is not subscriptable
Ran a couple time into this bug, and found it really hard to debug within stable baselines.
To spare others (as well as my future self) much frustration I would suggest to add a type check to wrapper envs like dummyEnv (or only check_env?) before using the action to make sure it's an iterable, before continuing with the code.
The following example assertion will give a developer friendly error message that's easy to understand and offers an immediate solution, saving much frustration.
Code example
#40 (comment)
Proposed Solution
for https://github.com/hill-a/stable-baselines/blob/master/stable_baselines/common/vec_env/dummy_vec_env.py#L37
The text was updated successfully, but these errors were encountered: