-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 Framestack obs env_checker #1574
base: master
Are you sure you want to change the base?
Conversation
Thank you @corentinlger! Are we sure that everything is working with an environment that returns |
Where do you need to update the type hint? |
Yes I checked with several FrameStacked envs that returned LazyFrames observations and everything worked ! If I am not wrong, when using np.can_cast I needed to update the type hint on the 'check_obs' function. When I ran make pytype I got this error : ''' With the other option I just added LazyFrames to the obs type hint as follows : "obs: Union[tuple, dict, np.ndarray, int, LazyFrames]" and it worked. Do you think there is a better way to solve the problem ? |
Co-authored-by: Quentin Gallouédec <[email protected]>
Fix env_checker function for gymnasium FrameStacked observations (previously raised an error)
Description
FrameStacked obs from Gymnasium only support Box obs and are stored in a LazyFrames class. Because the associated obs_space is a np.ndarray, I only added a condition where I still check if the obs is a np.ndarray class, but also a LazyFrames class (when _is_numpy_array_space is True).
@qgallouedec also proposed to use np.can_cast which worked, but the type hinting for the function became really long (and could lead to errors) because you can also cast str, bytes ... So I don't know if the solution used here is the best but it seems to work. What do you think about it ?
Motivation and Context
Solves the problem mentionned in this issue.
closes #1500
Types of changes
Checklist
make format
(required)make check-codestyle
andmake lint
(required)make pytest
andmake type
both pass. (required) --> I don't have a GPU and had a segmentation error by running 'make pytest'make doc
(required)Note: You can run most of the checks using
make commit-checks
.Note: we are using a maximum length of 127 characters per line