Skip to content

Commit

Permalink
Pre commit autoupdate (#1082)
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudo-rnd-thoughts authored Jun 10, 2024
1 parent b58207f commit 52b6878
Show file tree
Hide file tree
Showing 119 changed files with 159 additions and 63 deletions.
1 change: 0 additions & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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"]
Expand All @@ -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
Expand Down
35 changes: 17 additions & 18 deletions docs/environments/mujoco.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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** | |
Expand All @@ -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) |

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/tutorials/gymnasium_basics/vector_envs_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
======================================================
"""

# %%
# Notice
# ------
Expand Down
1 change: 0 additions & 1 deletion docs/tutorials/training_agents/FrozenLake_tuto.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""


# %%
# In this post we'll compare a bunch of different map sizes on the
# `FrozenLake <https://gymnasium.farama.org/environments/toy_text/frozen_lake/>`__
Expand Down
1 change: 1 addition & 0 deletions gymnasium/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Root `__init__` of the gymnasium module setting the `__all__` of gymnasium modules."""

# isort: skip_file

from gymnasium.core import (
Expand Down
1 change: 1 addition & 0 deletions gymnasium/core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Core API for Environment, Wrapper, ActionWrapper, RewardWrapper and ObservationWrapper."""

from __future__ import annotations

from copy import deepcopy
Expand Down
1 change: 1 addition & 0 deletions gymnasium/envs/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions gymnasium/envs/box2d/bipedal_walker.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def __init__(self, render_mode: Optional[str] = None, hardcore: bool = False):
# 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,
Expand Down Expand Up @@ -569,7 +569,7 @@ def step(self, action: np.ndarray):
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,
Expand Down
8 changes: 2 additions & 6 deletions gymnasium/envs/classic_control/acrobot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""classic Acrobot task"""

from typing import Optional

import numpy as np
Expand Down Expand Up @@ -256,12 +257,7 @@ def _dsdt(self, s_augmented):
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 = (
Expand Down
1 change: 1 addition & 0 deletions gymnasium/envs/classic_control/cartpole.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Copied from http://incompleteideas.net/sutton/book/code/pole.c
permalink: https://perma.cc/C9ZM-652R
"""

import math
from typing import Optional, Tuple, Union

Expand Down
1 change: 1 addition & 0 deletions gymnasium/envs/classic_control/mountain_car.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
http://incompleteideas.net/MountainCar/MountainCar1.cp
permalink: https://perma.cc/6Z2N-PFWC
"""

import math
from typing import Optional

Expand Down
1 change: 1 addition & 0 deletions gymnasium/envs/functional_jax_env.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functional to Environment compatibility."""

from __future__ import annotations

from typing import Any
Expand Down
1 change: 1 addition & 0 deletions gymnasium/envs/phys2d/__init__.py
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions gymnasium/envs/phys2d/cartpole.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of a Jax-accelerated cartpole environment."""

from __future__ import annotations

from typing import Any, Tuple
Expand Down
1 change: 1 addition & 0 deletions gymnasium/envs/phys2d/pendulum.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of a Jax-accelerated pendulum environment."""

from __future__ import annotations

from os import path
Expand Down
7 changes: 3 additions & 4 deletions gymnasium/envs/registration.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Functions for registering environments within gymnasium using public functions ``make``, ``register`` and ``spec``."""

from __future__ import annotations

import contextlib
Expand Down Expand Up @@ -52,15 +53,13 @@
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
Expand Down
1 change: 0 additions & 1 deletion gymnasium/envs/tabular/blackjack.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 0 additions & 1 deletion gymnasium/envs/tabular/cliffwalking.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""This module provides a CliffWalking functional environment and Gymnasium environment wrapper CliffWalkingJaxEnv."""


from __future__ import annotations

from os import path
Expand Down
12 changes: 6 additions & 6 deletions gymnasium/envs/toy_text/frozen_lake.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,12 @@ def inc(row, col, a):
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):
Expand Down
1 change: 1 addition & 0 deletions gymnasium/functional.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions gymnasium/logger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Set of functions for logging messages."""

import sys
import warnings
from typing import Optional, Type
Expand Down
1 change: 1 addition & 0 deletions gymnasium/spaces/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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
Expand Down
1 change: 1 addition & 0 deletions gymnasium/spaces/box.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions gymnasium/spaces/dict.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions gymnasium/spaces/discrete.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of a space consisting of finitely many elements."""

from __future__ import annotations

from typing import Any, Iterable, Mapping, Sequence
Expand Down
4 changes: 2 additions & 2 deletions gymnasium/spaces/graph.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -176,8 +177,7 @@ def seed(

def sample(
self,
mask: None
| (
mask: None | (
tuple[
NDArray[Any] | tuple[Any, ...] | None,
NDArray[Any] | tuple[Any, ...] | None,
Expand Down
1 change: 1 addition & 0 deletions gymnasium/spaces/multi_binary.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions gymnasium/spaces/multi_discrete.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions gymnasium/spaces/oneof.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of a space that represents the cartesian product of other spaces."""

from __future__ import annotations

import typing
Expand Down
4 changes: 2 additions & 2 deletions gymnasium/spaces/sequence.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of a space that represents finite-length sequences."""

from __future__ import annotations

import typing
Expand Down Expand Up @@ -100,8 +101,7 @@ def is_np_flattenable(self):

def sample(
self,
mask: None
| (
mask: None | (
tuple[
None | np.integer | NDArray[np.integer],
Any,
Expand Down
1 change: 1 addition & 0 deletions gymnasium/spaces/space.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of the `Space` metaclass."""

from __future__ import annotations

from typing import Any, Generic, Iterable, Mapping, Sequence, TypeVar
Expand Down
1 change: 1 addition & 0 deletions gymnasium/spaces/text.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of a space that represents textual strings."""

from __future__ import annotations

from typing import Any
Expand Down
1 change: 1 addition & 0 deletions gymnasium/spaces/tuple.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of a space that represents the cartesian product of other spaces."""

from __future__ import annotations

import typing
Expand Down
Loading

0 comments on commit 52b6878

Please sign in to comment.