Skip to content

[Bug Report] Rendering broken in v0.25 #2972

@vmoens

Description

@vmoens

Describe the bug
Rendering is broken for simple envs (e.g. Pendulum-v1)

Code example

import gym
from gym.wrappers.pixel_observation import PixelObservationWrapper
PixelObservationWrapper(gym.make("Pendulum-v1")).reset()

Error stack:

/path/to/venv/python3.8/site-packages/gym/wrappers/pixel_observation.py in __init__(self, env, pixels_only, render_kwargs, pixel_keys)
    131             pixels: np.ndarray = pixels[-1] if isinstance(pixels, List) else pixels
    132 
--> 133             if np.issubdtype(pixels.dtype, np.integer):
    134                 low, high = (0, 255)
    135             elif np.issubdtype(pixels.dtype, np.float):

AttributeError: 'NoneType' object has no attribute 'dtype'

System Info
Describe the characteristic of your environment:

  • Describe how Gym was installed (pip, docker, source, ...)
pip install gym --upgrade
  • What OS/version of Linux you're using. Note that while we will accept PRs to improve Window's support, we do not officially support it.
    OsX (x86) and Unix
  • Python version
    3.7, 3.8, 3.9 and 3.10

Checklist

  • I have checked that there is no similar issue in the repo (required)

EDIT

I guess this is related to this (from the release note)

Render - The render API is changed such that the mode has to be specified during gym.make with the keyword render_mode, after which, the render mode is fixed. For further details see https://younis.dev/blog/2022/render-api/ and #2671. This has the additional changes
with render_mode="human" you don't need to call .render(), rendering will happen automatically on env.step()
with render_mode="rgb_array", .render() pops the list of frames rendered since the last .reset()
with render_mode="single_rgb_array", .render() returns a single frame, like before.

Specifying render_mode="single_rgb_array" solves it, but it is a bc-breaking change. Any chance we can get a default value there?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions