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 <45557362+qgallouedec@users.noreply.github.com>
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-codestyleandmake lint(required)make pytestandmake typeboth 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