mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-07-31 05:44:31 +00:00
Pre commit autoupdate (#1082)
This commit is contained in:
1
.github/workflows/pre-commit.yml
vendored
1
.github/workflows/pre-commit.yml
vendored
@@ -17,5 +17,4 @@ jobs:
|
||||
- uses: actions/setup-python@v5
|
||||
- run: python -m pip install pre-commit
|
||||
- run: python -m pre_commit --version
|
||||
- run: python -m pre_commit install
|
||||
- run: python -m pre_commit run --all-files
|
||||
|
@@ -2,7 +2,7 @@
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.5.0
|
||||
rev: v4.6.0
|
||||
hooks:
|
||||
- id: check-symlinks
|
||||
- id: destroyed-symlinks
|
||||
@@ -18,7 +18,7 @@ repos:
|
||||
- id: detect-private-key
|
||||
- id: debug-statements
|
||||
- repo: https://github.com/codespell-project/codespell
|
||||
rev: v2.2.6
|
||||
rev: v2.3.0
|
||||
hooks:
|
||||
- id: codespell
|
||||
args:
|
||||
@@ -35,7 +35,7 @@ repos:
|
||||
- --show-source
|
||||
- --statistics
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.15.0
|
||||
rev: v3.16.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: ["--py38-plus"]
|
||||
@@ -44,7 +44,7 @@ repos:
|
||||
hooks:
|
||||
- id: isort
|
||||
- repo: https://github.com/python/black
|
||||
rev: 23.12.1
|
||||
rev: 24.4.2
|
||||
hooks:
|
||||
- id: black
|
||||
- repo: https://github.com/pycqa/pydocstyle
|
||||
|
@@ -41,8 +41,9 @@ Instructions for installing the MuJoCo engine can be found on their [website](ht
|
||||
For MuJoCo `v3` environments and older the `mujoco-py` framework is required (`pip install gymnasium[mujoco-py]`) which can be found in the [GitHub repository](https://github.com/openai/mujoco-py/tree/master/mujoco_py).
|
||||
|
||||
There are eleven MuJoCo environments (in roughly increasing complexity):
|
||||
|
||||
| Robot | Short Description |
|
||||
| ---------------------- | -------------------------------------------------------------------- |
|
||||
|------------------------|----------------------------------------------------------------------|
|
||||
| **CartPoles** | |
|
||||
| InvertedPendulum | MuJoCo version of the CartPole Environment (with Continuous actions) |
|
||||
| InvertedDoublePendulum | 2 Pole variation of the CartPole Environment |
|
||||
@@ -51,8 +52,8 @@ There are eleven MuJoCo environments (in roughly increasing complexity):
|
||||
| Pusher | 3d arm with the goal of pushing an object to a target location |
|
||||
| **2D Runners** | |
|
||||
| HalfCheetah | 2d quadruped with the goal of running |
|
||||
| Hopper | 2d monoped with the goal of hopping |
|
||||
| Walker2d | 2d biped with the goal of walking |
|
||||
| Hopper | 2d monoped with the goal of hopping |
|
||||
| Walker2d | 2d biped with the goal of walking |
|
||||
| **Swimmers** | |
|
||||
| Swimmer | 3d robot with the goal of swimming |
|
||||
| **Quarduped** | |
|
||||
@@ -75,10 +76,10 @@ Environments can be configured by changing the `xml_file` argument and/or by twe
|
||||
## Versions
|
||||
Gymnasium includes the following versions of the environments:
|
||||
|
||||
| Version | Simulator | Notes |
|
||||
| ------- | --------------- | ------------------------------------------------ |
|
||||
| `v5` | `mujoco=>2.3.3` | Recommended (most features, the least bugs) |
|
||||
| `v4` | `mujoco=>2.1.3` | Maintained for reproducibility |
|
||||
| Version | Simulator | Notes |
|
||||
|---------|-----------------|--------------------------------------------------------|
|
||||
| `v5` | `mujoco=>2.3.3` | Recommended (most features, the least bugs) |
|
||||
| `v4` | `mujoco=>2.1.3` | Maintained for reproducibility |
|
||||
| `v3` | `mujoco-py` | Deprecated, Kept for reproducibility (limited support) |
|
||||
| `v2` | `mujoco-py` | Deprecated, Kept for reproducibility (limited support) |
|
||||
|
||||
@@ -103,17 +104,15 @@ All of the MuJoCo Environments besides the general Gymnasium arguments, and envi
|
||||
env = gymnasium.make("Ant-v5", render_mode="rgb_array", width=1280, height=720)
|
||||
```
|
||||
|
||||
| Parameter | Type | Default | Description |
|
||||
| --------------------------- | ------------- | ------------ | ----------------------------------------- |
|
||||
| `width` | **int** | `480` | The width of the render window |
|
||||
| `height` | **int** | `480` | The height of the render window |
|
||||
| `camera_id` |**int \| None** | `None` | The camera ID used for the render window |
|
||||
| `camera_name` |**str \| None** | `None` | The name of the camera used for the render window (mutally exclusive option with `camera_id`) |
|
||||
| `default_camera_config` |**dict[str, float \| int] \| None**| `None` | The [mjvCamera](https://mujoco.readthedocs.io/en/stable/APIreference/APItypes.html#mjvcamera) properties |
|
||||
| `max_geom` | **int** | `1000` | Max number of geometrical objects to render (useful for 3rd-party environments) |
|
||||
| `visual_options` | **Dict[int, bool]** | `{}` | A dictionary with [mjVisual](https://mujoco.readthedocs.io/en/stable/overview.html#mjvisual) flags and value pairs, example `{mujoco.mjtVisFlag.mjVIS_CONTACTPOINT: True, mujoco.mjtVisFlag.mjVIS_CONTACTFORCE: True}` (show contact points and forces). |
|
||||
|
||||
|
||||
| Parameter | Type | Default | Description |
|
||||
|-------------------------|-------------------------------------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `width` | **int** | `480` | The width of the render window |
|
||||
| `height` | **int** | `480` | The height of the render window |
|
||||
| `camera_id` | **int \| None** | `None` | The camera ID used for the render window |
|
||||
| `camera_name` | **str \| None** | `None` | The name of the camera used for the render window (mutually exclusive option with `camera_id`) |
|
||||
| `default_camera_config` | **dict[str, float \| int] \| None** | `None` | The [mjvCamera](https://mujoco.readthedocs.io/en/stable/APIreference/APItypes.html#mjvcamera) properties |
|
||||
| `max_geom` | **int** | `1000` | Max number of geometrical objects to render (useful for 3rd-party environments) |
|
||||
| `visual_options` | **Dict[int, bool]** | `{}` | A dictionary with [mjVisual](https://mujoco.readthedocs.io/en/stable/overview.html#mjvisual) flags and value pairs, example `{mujoco.mjtVisFlag.mjVIS_CONTACTPOINT: True, mujoco.mjtVisFlag.mjVIS_CONTACTFORCE: True}` (show contact points and forces). |
|
||||
|
||||
<!--
|
||||
## Custom Models
|
||||
|
@@ -3,6 +3,7 @@ Training A2C with Vector Envs and Domain Randomization
|
||||
======================================================
|
||||
|
||||
"""
|
||||
|
||||
# %%
|
||||
# Notice
|
||||
# ------
|
||||
|
@@ -4,7 +4,6 @@ Frozenlake benchmark
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# %%
|
||||
# In this post we'll compare a bunch of different map sizes on the
|
||||
# `FrozenLake <https://gymnasium.farama.org/environments/toy_text/frozen_lake/>`__
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Root `__init__` of the gymnasium module setting the `__all__` of gymnasium modules."""
|
||||
|
||||
# isort: skip_file
|
||||
|
||||
from gymnasium.core import (
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Core API for Environment, Wrapper, ActionWrapper, RewardWrapper and ObservationWrapper."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from copy import deepcopy
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Registers the internal gym envs then loads the env plugins for module using the entry point."""
|
||||
|
||||
from typing import Any
|
||||
|
||||
from gymnasium.envs.registration import make, pprint_registry, register, registry, spec
|
||||
|
@@ -250,7 +250,7 @@ class BipedalWalker(gym.Env, EzPickle):
|
||||
# 0.3 * vel.y * (VIEWPORT_H / SCALE) / FPS,
|
||||
# self.joints[
|
||||
# 0
|
||||
# ].angle, # This will give 1.1 on high up, but it's still OK (and there should be spikes on hiting the ground, that's normal too)
|
||||
# ].angle, # This will give 1.1 on high up, but it's still OK (and there should be spikes on hitting the ground, that's normal too)
|
||||
# self.joints[0].speed / SPEED_HIP,
|
||||
# self.joints[1].angle + 1.0,
|
||||
# self.joints[1].speed / SPEED_KNEE,
|
||||
@@ -569,7 +569,7 @@ class BipedalWalker(gym.Env, EzPickle):
|
||||
0.3 * vel.x * (VIEWPORT_W / SCALE) / FPS, # Normalized to get -1..1 range
|
||||
0.3 * vel.y * (VIEWPORT_H / SCALE) / FPS,
|
||||
self.joints[0].angle,
|
||||
# This will give 1.1 on high up, but it's still OK (and there should be spikes on hiting the ground, that's normal too)
|
||||
# This will give 1.1 on high up, but it's still OK (and there should be spikes on hitting the ground, that's normal too)
|
||||
self.joints[0].speed / SPEED_HIP,
|
||||
self.joints[1].angle + 1.0,
|
||||
self.joints[1].speed / SPEED_KNEE,
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""classic Acrobot task"""
|
||||
|
||||
from typing import Optional
|
||||
|
||||
import numpy as np
|
||||
@@ -256,12 +257,7 @@ class AcrobotEnv(Env):
|
||||
theta2 = s[1]
|
||||
dtheta1 = s[2]
|
||||
dtheta2 = s[3]
|
||||
d1 = (
|
||||
m1 * lc1**2
|
||||
+ m2 * (l1**2 + lc2**2 + 2 * l1 * lc2 * cos(theta2))
|
||||
+ I1
|
||||
+ I2
|
||||
)
|
||||
d1 = m1 * lc1**2 + m2 * (l1**2 + lc2**2 + 2 * l1 * lc2 * cos(theta2)) + I1 + I2
|
||||
d2 = m2 * (lc2**2 + l1 * lc2 * cos(theta2)) + I2
|
||||
phi2 = m2 * lc2 * g * cos(theta1 + theta2 - pi / 2.0)
|
||||
phi1 = (
|
||||
|
@@ -3,6 +3,7 @@ Classic cart-pole system implemented by Rich Sutton et al.
|
||||
Copied from http://incompleteideas.net/sutton/book/code/pole.c
|
||||
permalink: https://perma.cc/C9ZM-652R
|
||||
"""
|
||||
|
||||
import math
|
||||
from typing import Optional, Tuple, Union
|
||||
|
||||
|
@@ -2,6 +2,7 @@
|
||||
http://incompleteideas.net/MountainCar/MountainCar1.cp
|
||||
permalink: https://perma.cc/6Z2N-PFWC
|
||||
"""
|
||||
|
||||
import math
|
||||
from typing import Optional
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Functional to Environment compatibility."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
@@ -1,3 +1,4 @@
|
||||
"""Module for 2d physics environments with functional and environment implementations."""
|
||||
|
||||
from gymnasium.envs.phys2d.cartpole import CartPoleFunctional, CartPoleJaxEnv
|
||||
from gymnasium.envs.phys2d.pendulum import PendulumFunctional, PendulumJaxEnv
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Implementation of a Jax-accelerated cartpole environment."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Tuple
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Implementation of a Jax-accelerated pendulum environment."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from os import path
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Functions for registering environments within gymnasium using public functions ``make``, ``register`` and ``spec``."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
@@ -52,15 +53,13 @@ __all__ = [
|
||||
class EnvCreator(Protocol):
|
||||
"""Function type expected for an environment."""
|
||||
|
||||
def __call__(self, **kwargs: Any) -> Env:
|
||||
...
|
||||
def __call__(self, **kwargs: Any) -> Env: ...
|
||||
|
||||
|
||||
class VectorEnvCreator(Protocol):
|
||||
"""Function type expected for an environment."""
|
||||
|
||||
def __call__(self, **kwargs: Any) -> gym.vector.VectorEnv:
|
||||
...
|
||||
def __call__(self, **kwargs: Any) -> gym.vector.VectorEnv: ...
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@@ -1,6 +1,5 @@
|
||||
"""This module provides a Blackjack functional environment and Gymnasium environment wrapper BlackJackJaxEnv."""
|
||||
|
||||
|
||||
import math
|
||||
import os
|
||||
from typing import NamedTuple, Optional, Tuple, Union
|
||||
|
@@ -1,6 +1,5 @@
|
||||
"""This module provides a CliffWalking functional environment and Gymnasium environment wrapper CliffWalkingJaxEnv."""
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from os import path
|
||||
|
@@ -253,12 +253,12 @@ class FrozenLakeEnv(Env):
|
||||
return (row, col)
|
||||
|
||||
def update_probability_matrix(row, col, action):
|
||||
newrow, newcol = inc(row, col, action)
|
||||
newstate = to_s(newrow, newcol)
|
||||
newletter = desc[newrow, newcol]
|
||||
terminated = bytes(newletter) in b"GH"
|
||||
reward = float(newletter == b"G")
|
||||
return newstate, reward, terminated
|
||||
new_row, new_col = inc(row, col, action)
|
||||
new_state = to_s(new_row, new_col)
|
||||
new_letter = desc[new_row, new_col]
|
||||
terminated = bytes(new_letter) in b"GH"
|
||||
reward = float(new_letter == b"G")
|
||||
return new_state, reward, terminated
|
||||
|
||||
for row in range(nrow):
|
||||
for col in range(ncol):
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Base class and definitions for an alternative, functional backend for gym envs, particularly suitable for hardware accelerated and otherwise transformed environments."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Callable, Generic, TypeVar
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Set of functions for logging messages."""
|
||||
|
||||
import sys
|
||||
import warnings
|
||||
from typing import Optional, Type
|
||||
|
@@ -10,6 +10,7 @@ are vectors in the two-dimensional unit cube, the environment code may contain t
|
||||
|
||||
All spaces inherit from the :class:`Space` superclass.
|
||||
"""
|
||||
|
||||
from gymnasium.spaces.box import Box
|
||||
from gymnasium.spaces.dict import Dict
|
||||
from gymnasium.spaces.discrete import Discrete
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Implementation of a space that represents closed boxes in euclidean space."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Iterable, Mapping, Sequence, SupportsFloat
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Implementation of a space that represents the cartesian product of other spaces as a dictionary."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import collections.abc
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Implementation of a space consisting of finitely many elements."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Iterable, Mapping, Sequence
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Implementation of a space that represents graph information where nodes and edges can be represented with euclidean space."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, NamedTuple, Sequence
|
||||
@@ -176,8 +177,7 @@ class Graph(Space[GraphInstance]):
|
||||
|
||||
def sample(
|
||||
self,
|
||||
mask: None
|
||||
| (
|
||||
mask: None | (
|
||||
tuple[
|
||||
NDArray[Any] | tuple[Any, ...] | None,
|
||||
NDArray[Any] | tuple[Any, ...] | None,
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Implementation of a space that consists of binary np.ndarrays of a fixed shape."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Sequence
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Implementation of a space that represents the cartesian product of `Discrete` spaces."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Iterable, Mapping, Sequence
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Implementation of a space that represents the cartesian product of other spaces."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import typing
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Implementation of a space that represents finite-length sequences."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import typing
|
||||
@@ -100,8 +101,7 @@ class Sequence(Space[Union[typing.Tuple[Any, ...], Any]]):
|
||||
|
||||
def sample(
|
||||
self,
|
||||
mask: None
|
||||
| (
|
||||
mask: None | (
|
||||
tuple[
|
||||
None | np.integer | NDArray[np.integer],
|
||||
Any,
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Implementation of the `Space` metaclass."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Generic, Iterable, Mapping, Sequence, TypeVar
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Implementation of a space that represents textual strings."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Implementation of a space that represents the cartesian product of other spaces."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import typing
|
||||
|
@@ -3,6 +3,7 @@
|
||||
These functions mostly take care of flattening and unflattening elements of spaces
|
||||
to facilitate their usage in learning code.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import operator as op
|
||||
@@ -538,9 +539,9 @@ def _flatten_space_dict(space: Dict) -> Box | Dict:
|
||||
def _flatten_space_graph(space: Graph) -> Graph:
|
||||
return Graph(
|
||||
node_space=flatten_space(space.node_space),
|
||||
edge_space=flatten_space(space.edge_space)
|
||||
if space.edge_space is not None
|
||||
else None,
|
||||
edge_space=(
|
||||
flatten_space(space.edge_space) if space.edge_space is not None else None
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Class for pickling and unpickling objects via their constructor arguments."""
|
||||
|
||||
from typing import Any
|
||||
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""A set of functions for passively checking environment implementations."""
|
||||
|
||||
import inspect
|
||||
from functools import partial
|
||||
from typing import Callable
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Utilities of visualising an environment."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections import deque
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Allows attributes passed to `RecordConstructorArgs` to be saved. This is used by the `Wrapper.spec` to know the constructor arguments of implemented wrappers."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from copy import deepcopy
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Utility functions to save rendering videos."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Set of random number generator functions: seeding, generator, hashing seeds."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Contains methods for step compatibility, from old-to-new and new-to-old API."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import SupportsFloat, Tuple, Union
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Experimental vector env API."""
|
||||
|
||||
from gymnasium.vector import utils
|
||||
from gymnasium.vector.async_vector_env import AsyncVectorEnv
|
||||
from gymnasium.vector.sync_vector_env import SyncVectorEnv
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""An async vector environment."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import multiprocessing
|
||||
@@ -90,10 +91,12 @@ class AsyncVectorEnv(VectorEnv):
|
||||
copy: bool = True,
|
||||
context: str | None = None,
|
||||
daemon: bool = True,
|
||||
worker: Callable[
|
||||
[int, Callable[[], Env], Connection, Connection, bool, Queue], None
|
||||
]
|
||||
| None = None,
|
||||
worker: (
|
||||
Callable[
|
||||
[int, Callable[[], Env], Connection, Connection, bool, Queue], None
|
||||
]
|
||||
| None
|
||||
) = None,
|
||||
):
|
||||
"""Vectorized environment that runs multiple environments in parallel.
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Implementation of a synchronous (for loop) vectorization method of any environment."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from copy import deepcopy
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Miscellaneous utilities."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Utility functions for vector environments to share memory between processes."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import multiprocessing as mp
|
||||
|
@@ -5,6 +5,7 @@
|
||||
- ``Iterate``: Iterate over the elements of a (batched) space and items.
|
||||
- ``create_empty_array``: Create an empty (possibly nested) (normally numpy-based) array, used in conjunction with ``concatenate(..., out=array)``
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from copy import deepcopy
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Base class for vectorized environments."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Generic, TypeVar
|
||||
@@ -95,8 +96,9 @@ class VectorEnv(Generic[ObsType, ActType, ArrayType]):
|
||||
|
||||
To avoid having to wait for all sub-environments to terminated before resetting, implementations will autoreset
|
||||
sub-environments on episode end (`terminated or truncated is True`). As a result, when adding observations
|
||||
to a replay buffer, this requires a knowning where the observation (and info) for each sub-environment are the first
|
||||
observation from an autoreset. We recommend using an additional variable to store this information.
|
||||
to a replay buffer, this requires knowing when an observation (and info) for each sub-environment are the first
|
||||
observation from an autoreset. We recommend using an additional variable to store this information such as
|
||||
``has_autoreset = np.logical_or(terminated, truncated)``.
|
||||
|
||||
The Vector Environments have the additional attributes for users to understand the implementation
|
||||
|
||||
|
@@ -45,6 +45,7 @@ If you need a wrapper to do more complicated tasks, you can inherit from the :cl
|
||||
|
||||
If you'd like to implement your own custom wrapper, check out `the corresponding tutorial <../../tutorials/implementing_custom_wrappers>`_.
|
||||
"""
|
||||
|
||||
# pyright: reportUnsupportedDunderAll=false
|
||||
import importlib
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Implementation of Atari 2600 Preprocessing following the guidelines of Machado et al., 2018."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, SupportsFloat
|
||||
|
@@ -6,6 +6,7 @@
|
||||
* ``OrderEnforcing`` - Enforces the order of function calls to environments
|
||||
* ``RecordEpisodeStatistics`` - Records the episode statistics
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Helper functions and wrapper class for converting between numpy and Jax."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import functools
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Helper functions and wrapper class for converting between PyTorch and NumPy."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import functools
|
||||
|
@@ -4,6 +4,7 @@
|
||||
* ``RecordVideo`` - Records a video of the environments
|
||||
* ``HumanRendering`` - Provides human rendering of environments with ``"rgb_array"``
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""``StickyAction`` wrapper - There is a probability that the action is taken again."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
@@ -6,6 +6,7 @@
|
||||
* ``NormalizeObservation`` - Normalized the observations to have unit variance with a moving mean
|
||||
* ``MaxAndSkipObservation`` - Return only every ``skip``-th frame (frameskipping) and return the max between the two last frames.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections import deque
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
* ``NormalizeReward`` - Normalizes the rewards to a mean and standard deviation
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, SupportsFloat
|
||||
|
@@ -4,6 +4,7 @@
|
||||
* ``ClipAction`` - Clips the action within a bounds
|
||||
* ``RescaleAction`` - Rescales the action within a minimum and maximum actions
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Callable
|
||||
|
@@ -10,6 +10,7 @@
|
||||
* ``DtypeObservation`` - Convert an observation to a dtype
|
||||
* ``RenderObservation`` - Allows the observation to the rendered frame
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Callable, Final, Sequence
|
||||
|
@@ -3,6 +3,7 @@
|
||||
* ``TransformReward`` - Transforms the reward by a function
|
||||
* ``ClipReward`` - Clips the reward between a minimum and maximum value
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Callable, SupportsFloat
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Utility functions for the wrappers."""
|
||||
|
||||
from functools import singledispatch
|
||||
|
||||
import numpy as np
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Wrappers for vector environments."""
|
||||
|
||||
# pyright: reportUnsupportedDunderAll=false
|
||||
import importlib
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Wrapper that tracks the cumulative rewards and episode lengths."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Wrapper that converts the info format for vec envs into the list format."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Vector wrapper for converting between NumPy and Jax."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Vector wrapper class for converting between PyTorch and Jax."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Wrapper for converting NumPy environments to PyTorch."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""File for rendering of vector-based environments."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from copy import deepcopy
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
* ``NormalizeObservation`` - Normalize the observations
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
* ``NormalizeReward`` - Normalizes the rewards to a mean and standard deviation
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, SupportsFloat
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Vectorizes action wrappers to work for `VectorEnv`."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from copy import deepcopy
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Vectorizes observation wrappers to works for `VectorEnv`."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from copy import deepcopy
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Vectorizes reward function to work with `VectorEnv`."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Callable
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Test for the `EnvSpec`, in particular, a full integration with `EnvSpec`."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Tests that `gym.make` works as expected."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Testing of the `gym.make_vec` function."""
|
||||
|
||||
import re
|
||||
|
||||
import pytest
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Tests that `gymnasium.register` works as expected."""
|
||||
|
||||
import re
|
||||
from typing import Optional
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""This utility file contains an environment that is registered upon loading the file."""
|
||||
|
||||
import gymnasium as gym
|
||||
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Finds all the specs that we can test with"""
|
||||
|
||||
from typing import List, Optional
|
||||
|
||||
import gymnasium as gym
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Tests the functional api."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
@@ -1,6 +1,5 @@
|
||||
"""Tests for Jax Blackjack functional env."""
|
||||
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
|
@@ -1,6 +1,5 @@
|
||||
"""Tests for Jax cliffwalking functional env."""
|
||||
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Checks that the core Gymnasium API is implemented as expected."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Provides a generic testing environment for use in tests with custom reset, step and render functions."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import types
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Tests that the `env_checker` runs as expects and all errors are possible."""
|
||||
|
||||
import re
|
||||
import warnings
|
||||
from typing import Callable, Tuple, Union
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Test the vector environment information."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, SupportsFloat
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Tests the vector wrappers work as expected."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Testing utilitys for `gymnasium.vector`."""
|
||||
|
||||
import time
|
||||
from typing import Optional
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Utility functions for testing the vector utility functions."""
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Test suite for RenderObservation wrapper."""
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Test suite for Autoreset wrapper."""
|
||||
|
||||
import numpy as np
|
||||
|
||||
import gymnasium as gym
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Test suite for ClipReward wrapper."""
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Test suite for DelayObservation wrapper."""
|
||||
|
||||
import re
|
||||
|
||||
import pytest
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Test suite for DtypeObservation wrapper."""
|
||||
|
||||
import numpy as np
|
||||
|
||||
from gymnasium.wrappers import DtypeObservation
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Test suite for FilterObservation wrapper."""
|
||||
|
||||
import pytest
|
||||
|
||||
from gymnasium.spaces import Box, Dict, Tuple
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Test suite for FrameStackObservation wrapper."""
|
||||
|
||||
import re
|
||||
|
||||
import numpy as np
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Test suite for GrayscaleObservation wrapper."""
|
||||
|
||||
import numpy as np
|
||||
|
||||
from gymnasium.spaces import Box
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Test suite of HumanRendering wrapper."""
|
||||
|
||||
import re
|
||||
|
||||
import pytest
|
||||
|
@@ -1,4 +1,5 @@
|
||||
"""Test suite for import wrappers."""
|
||||
|
||||
import re
|
||||
|
||||
import pytest
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user