-
-
Notifications
You must be signed in to change notification settings - Fork 953
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
Fix VectorizeActionTransform
for changing spaces
#1170
Fix VectorizeActionTransform
for changing spaces
#1170
Conversation
tuple( | ||
self.wrapper.func(action) | ||
for action in iterate(self.env.action_space, actions) | ||
for action in iterate(self.action_space, actions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: why not self.single_action_space
?
Docstring of iterate
: "space: Observation space of a single environment in the vectorized environment."
Same docstring in concatenate
which also takes as input a single_action_space
. (also both docstrings are completely identical, the one for iterate is wrong).
This seems to suggest that iterate
takes as argument the action space of a single action, not a batched one. Does it even matter since there is no out arg?
asking because I use it in my code, just want to make sure :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had just looked at the example docstring which shows a batched space rather than a single space so I'm using the batched space version.
I think the docstring is just incorrect, will update and check the rest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like someone, possibly me, copied the concatenate docstring for some reason, fixing now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick answers and fixes :)
I think in the end it does not matter whether the first arg is the batched space or not right? Both batched and unbatched versions of a same structured space should be identical up until the base spaces, which are iterated over just with iter
regardless of which space is given as argument. The only difference it makes is with respect to typing, and that is only if someone uses literal shape annotations in the base spaces.
One more little comment before I stop bothering you:
The signature of iterate
is:
def iterate(space: Space[T_cov], items: Iterable[T_cov])
but items
is supposed to be a single batched sample from space
->
def iterate(space: Space[T_cov], items: T_cov)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the second point, your correct, I'll update
Description
Fixes #1169
gymnasium.wrappers.vector.VectorizeActionTransform
was incorrectly implemented for changing spaces, i.e.,self.same_out is False
as the direction of data is the opposite ofVectorizeObservationTransform
from which it was copied.