Skip to content

Commit

Permalink
Swap width and height in RGBImgObsWrapper, add test (#445)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Catanzaro <[email protected]>
  • Loading branch information
catanzaromj and Michael Catanzaro authored Aug 24, 2024
1 parent 97438fb commit 715394f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion minigrid/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ def __init__(self, env, tile_size=8):
low=0,
high=255,
shape=(
self.unwrapped.width * tile_size,
self.unwrapped.height * tile_size,
self.unwrapped.width * tile_size,
3,
),
dtype="uint8",
Expand Down
10 changes: 10 additions & 0 deletions tests/test_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,3 +389,13 @@ def test_no_death_wrapper():
assert reward_wrap == reward + death_cost
env.close()
env_wrap.close()


def test_non_square_RGBIMgObsWrapper():
"""
Add test for non-square dimensions with RGBImgObsWrapper
(https://github.com/Farama-Foundation/Minigrid/issues/444).
"""
env = RGBImgObsWrapper(gym.make("MiniGrid-BlockedUnlockPickup-v0"))
obs, info = env.reset()
assert env.observation_space["image"].shape == obs["image"].shape

0 comments on commit 715394f

Please sign in to comment.