From 137be19330bf69171ef8c4523613562659e2e749 Mon Sep 17 00:00:00 2001 From: Kaibo He <37178760+Beanpow@users.noreply.github.com> Date: Fri, 25 Oct 2024 16:33:34 +0800 Subject: [PATCH] Add width and height check for MujocoRenderer (#1230) --- gymnasium/envs/mujoco/mujoco_rendering.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gymnasium/envs/mujoco/mujoco_rendering.py b/gymnasium/envs/mujoco/mujoco_rendering.py index e1ffe3abb..26f2806f0 100644 --- a/gymnasium/envs/mujoco/mujoco_rendering.py +++ b/gymnasium/envs/mujoco/mujoco_rendering.py @@ -702,6 +702,10 @@ def render( Returns: If render_mode is "rgb_array" or "depth_array" it returns a numpy array in the specified format. "human" render mode does not return anything. """ + if render_mode != "human": + assert ( + self.width is not None and self.height is not None + ), f"The width: {self.width} and height: {self.height} cannot be `None` when the render_mode is not `human`." viewer = self._get_viewer(render_mode=render_mode)