diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d0d4d16d3..d1928b57b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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.4.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -10,18 +10,18 @@ repos: - id: check-docstring-first - repo: https://github.com/psf/black - rev: 23.9.1 + rev: 24.10.0 hooks: - id: black - repo: https://github.com/asottile/blacken-docs - rev: 1.16.0 + rev: 1.19.1 hooks: - id: blacken-docs additional_dependencies: [black==23.1.0] - repo: https://github.com/pycqa/flake8 - rev: 6.1.0 + rev: 7.1.1 hooks: - id: flake8 additional_dependencies: [flake8-docstrings] diff --git a/examples/demo_agents/video_plot_a2c.py b/examples/demo_agents/video_plot_a2c.py index 80d7a4fe8..5ab514ce2 100644 --- a/examples/demo_agents/video_plot_a2c.py +++ b/examples/demo_agents/video_plot_a2c.py @@ -9,6 +9,7 @@ :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/video_plot_a2c.jpg' from rlberry_research.agents.torch import A2CAgent diff --git a/examples/demo_agents/video_plot_mbqvi.py b/examples/demo_agents/video_plot_mbqvi.py index d98ddcf77..69d48812d 100644 --- a/examples/demo_agents/video_plot_mbqvi.py +++ b/examples/demo_agents/video_plot_mbqvi.py @@ -9,6 +9,7 @@ :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/video_plot_mbqvi.jpg' from rlberry_scool.agents.mbqvi import MBQVIAgent from rlberry_research.envs.finite import GridWorld diff --git a/examples/demo_agents/video_plot_ppo.py b/examples/demo_agents/video_plot_ppo.py index 8834c7960..f352e799a 100644 --- a/examples/demo_agents/video_plot_ppo.py +++ b/examples/demo_agents/video_plot_ppo.py @@ -9,6 +9,7 @@ :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/video_plot_a2c.jpg' from rlberry_research.agents.torch import PPOAgent diff --git a/examples/demo_agents/video_plot_rs_kernel_ucbvi.py b/examples/demo_agents/video_plot_rs_kernel_ucbvi.py index abd322e29..8b2dd88d5 100644 --- a/examples/demo_agents/video_plot_rs_kernel_ucbvi.py +++ b/examples/demo_agents/video_plot_rs_kernel_ucbvi.py @@ -9,6 +9,7 @@ :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/video_plot_rs_kernel_ucbvi.jpg' from rlberry_research.envs import Acrobot diff --git a/examples/demo_agents/video_plot_rsucbvi.py b/examples/demo_agents/video_plot_rsucbvi.py index 354474cbd..9011fff25 100644 --- a/examples/demo_agents/video_plot_rsucbvi.py +++ b/examples/demo_agents/video_plot_rsucbvi.py @@ -9,6 +9,7 @@ :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/video_plot_rsucbvi.jpg' from rlberry_research.agents import RSUCBVIAgent diff --git a/examples/demo_agents/video_plot_vi.py b/examples/demo_agents/video_plot_vi.py index d6551f208..745197d97 100644 --- a/examples/demo_agents/video_plot_vi.py +++ b/examples/demo_agents/video_plot_vi.py @@ -9,6 +9,7 @@ :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/video_plot_vi.jpg' from rlberry_scool.agents.dynprog import ValueIterationAgent diff --git a/examples/demo_bandits/plot_compare_index_bandits.py b/examples/demo_bandits/plot_compare_index_bandits.py index fe799b95e..b22463327 100644 --- a/examples/demo_bandits/plot_compare_index_bandits.py +++ b/examples/demo_bandits/plot_compare_index_bandits.py @@ -6,6 +6,7 @@ This script Compare several bandits agents and as a sub-product also shows how to use subplots in with `plot_writer_data` """ + import numpy as np import matplotlib.pyplot as plt from rlberry_research.envs.bandits import BernoulliBandit diff --git a/examples/demo_bandits/plot_mirror_bandit.py b/examples/demo_bandits/plot_mirror_bandit.py index bb09ce3c2..f5a546881 100644 --- a/examples/demo_bandits/plot_mirror_bandit.py +++ b/examples/demo_bandits/plot_mirror_bandit.py @@ -12,6 +12,7 @@ The code is in three parts: definition of environment, definition of agent, and finally definition of the experiment. """ + import numpy as np from rlberry.manager import ExperimentManager, read_writer_data diff --git a/examples/demo_env/example_atari_atlantis_vectorized_ppo.py b/examples/demo_env/example_atari_atlantis_vectorized_ppo.py index dcbb889df..7248785a8 100644 --- a/examples/demo_env/example_atari_atlantis_vectorized_ppo.py +++ b/examples/demo_env/example_atari_atlantis_vectorized_ppo.py @@ -11,6 +11,7 @@ :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/example_plot_atari_atlantis_vectorized_ppo.jpg' diff --git a/examples/demo_env/example_atari_breakout_vectorized_ppo.py b/examples/demo_env/example_atari_breakout_vectorized_ppo.py index 480d5a647..4ae0d7fff 100644 --- a/examples/demo_env/example_atari_breakout_vectorized_ppo.py +++ b/examples/demo_env/example_atari_breakout_vectorized_ppo.py @@ -11,6 +11,7 @@ :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/example_plot_atari_breakout_vectorized_ppo.jpg' diff --git a/examples/demo_env/video_plot_acrobot.py b/examples/demo_env/video_plot_acrobot.py index db23804a7..68210f419 100644 --- a/examples/demo_env/video_plot_acrobot.py +++ b/examples/demo_env/video_plot_acrobot.py @@ -9,6 +9,7 @@ :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/video_plot_acrobot.jpg' from rlberry_research.envs import Acrobot diff --git a/examples/demo_env/video_plot_apple_gold.py b/examples/demo_env/video_plot_apple_gold.py index 1f939b40b..70bbe818c 100644 --- a/examples/demo_env/video_plot_apple_gold.py +++ b/examples/demo_env/video_plot_apple_gold.py @@ -9,6 +9,7 @@ :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/video_plot_apple_gold.jpg' from rlberry_research.envs.benchmarks.grid_exploration.apple_gold import AppleGold from rlberry_scool.agents.dynprog import ValueIterationAgent diff --git a/examples/demo_env/video_plot_atari_freeway.py b/examples/demo_env/video_plot_atari_freeway.py index 6a4c2665f..51d6a1bfd 100644 --- a/examples/demo_env/video_plot_atari_freeway.py +++ b/examples/demo_env/video_plot_atari_freeway.py @@ -11,6 +11,7 @@ :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/video_plot_atari_freeway.jpg' diff --git a/examples/demo_env/video_plot_chain.py b/examples/demo_env/video_plot_chain.py index 46d954749..898033a64 100644 --- a/examples/demo_env/video_plot_chain.py +++ b/examples/demo_env/video_plot_chain.py @@ -8,6 +8,7 @@ :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/video_plot_chain.jpg' diff --git a/examples/demo_env/video_plot_gridworld.py b/examples/demo_env/video_plot_gridworld.py index 85647b84e..d3e4ac95e 100644 --- a/examples/demo_env/video_plot_gridworld.py +++ b/examples/demo_env/video_plot_gridworld.py @@ -10,6 +10,7 @@ .. video:: ../../video_plot_gridworld.mp4 :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/video_plot_gridworld.jpg' from rlberry_scool.agents.dynprog import ValueIterationAgent diff --git a/examples/demo_env/video_plot_mountain_car.py b/examples/demo_env/video_plot_mountain_car.py index 011fb8691..eb1f5ee16 100644 --- a/examples/demo_env/video_plot_mountain_car.py +++ b/examples/demo_env/video_plot_mountain_car.py @@ -8,6 +8,7 @@ :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/video_plot_montain_car.jpg' from rlberry_scool.agents.mbqvi import MBQVIAgent diff --git a/examples/demo_env/video_plot_old_gym_compatibility_wrapper_old_acrobot.py b/examples/demo_env/video_plot_old_gym_compatibility_wrapper_old_acrobot.py index fff06ce51..7afc65662 100644 --- a/examples/demo_env/video_plot_old_gym_compatibility_wrapper_old_acrobot.py +++ b/examples/demo_env/video_plot_old_gym_compatibility_wrapper_old_acrobot.py @@ -8,6 +8,7 @@ :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/video_plot_old_gym_acrobot.jpg' diff --git a/examples/demo_env/video_plot_pball.py b/examples/demo_env/video_plot_pball.py index e9765fa5f..0ba3724e0 100644 --- a/examples/demo_env/video_plot_pball.py +++ b/examples/demo_env/video_plot_pball.py @@ -8,6 +8,7 @@ :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/video_plot_pball.jpg' import numpy as np diff --git a/examples/demo_env/video_plot_rooms.py b/examples/demo_env/video_plot_rooms.py index 5119c8957..eb0ad2e03 100644 --- a/examples/demo_env/video_plot_rooms.py +++ b/examples/demo_env/video_plot_rooms.py @@ -8,6 +8,7 @@ :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/video_plot_rooms.jpg' from rlberry_research.envs.benchmarks.grid_exploration.nroom import NRoom diff --git a/examples/demo_env/video_plot_springcartpole.py b/examples/demo_env/video_plot_springcartpole.py index 24ae6478a..ad27316ef 100644 --- a/examples/demo_env/video_plot_springcartpole.py +++ b/examples/demo_env/video_plot_springcartpole.py @@ -11,6 +11,7 @@ :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/video_plot_springcartpole.jpg' from rlberry_research.envs.classic_control import SpringCartPole diff --git a/examples/demo_env/video_plot_twinrooms.py b/examples/demo_env/video_plot_twinrooms.py index f8ae6ab11..5f6e78e26 100644 --- a/examples/demo_env/video_plot_twinrooms.py +++ b/examples/demo_env/video_plot_twinrooms.py @@ -8,6 +8,7 @@ :width: 600 """ + # sphinx_gallery_thumbnail_path = 'thumbnails/video_plot_twinrooms.jpg' from rlberry_research.envs.benchmarks.generalization.twinrooms import TwinRooms diff --git a/examples/example_venv.py b/examples/example_venv.py index 3df45bb6a..1cb4b63dc 100644 --- a/examples/example_venv.py +++ b/examples/example_venv.py @@ -13,7 +13,6 @@ and are only there to give the script's text. """ - from rlberry.manager import with_venv, run_venv_xp diff --git a/examples/plot_checkpointing.py b/examples/plot_checkpointing.py index 3de689cb6..babdb4e05 100644 --- a/examples/plot_checkpointing.py +++ b/examples/plot_checkpointing.py @@ -8,6 +8,7 @@ This is a minimal example of how to create checkpoints while training your agents, and how to restore from a previous checkpoint. """ + from rlberry.agents import Agent from rlberry.manager import ExperimentManager from rlberry.manager import plot_writer_data diff --git a/examples/plot_writer_wrapper.py b/examples/plot_writer_wrapper.py index 4b28538de..e384c403b 100644 --- a/examples/plot_writer_wrapper.py +++ b/examples/plot_writer_wrapper.py @@ -19,7 +19,6 @@ `rlberry.manager.plot_writer_data` documentation for more information. """ - import numpy as np from rlberry_scool.envs import GridWorld diff --git a/rlberry/rendering/render_interface.py b/rlberry/rendering/render_interface.py index 5a3daac4e..8f710f17c 100644 --- a/rlberry/rendering/render_interface.py +++ b/rlberry/rendering/render_interface.py @@ -2,7 +2,6 @@ Interface that allows 2D rendering. """ - from abc import ABC, abstractmethod from rlberry.rendering.opengl_render2d import OpenGLRender2D diff --git a/rlberry/tests/test_agents_base.py b/rlberry/tests/test_agents_base.py index 89378f24d..539f9d798 100644 --- a/rlberry/tests/test_agents_base.py +++ b/rlberry/tests/test_agents_base.py @@ -6,7 +6,6 @@ """ - import pytest import numpy as np import sys diff --git a/rlberry/wrappers/tests/old_env/old_acrobot.py b/rlberry/wrappers/tests/old_env/old_acrobot.py index 35408486d..12ad3581f 100644 --- a/rlberry/wrappers/tests/old_env/old_acrobot.py +++ b/rlberry/wrappers/tests/old_env/old_acrobot.py @@ -219,10 +219,7 @@ def _dsdt(self, s_augmented, t): # the following line is consistent with the java implementation # and the book ddtheta2 = ( - a - + d2 / d1 * phi1 - - m2 * l1 * lc2 * dtheta1**2 * np.sin(theta2) - - phi2 + a + d2 / d1 * phi1 - m2 * l1 * lc2 * dtheta1**2 * np.sin(theta2) - phi2 ) / (m2 * lc2**2 + I2 - d2**2 / d1) ddtheta1 = -(d2 * ddtheta2 + phi1) / d1 return (dtheta1, dtheta2, ddtheta1, ddtheta2, 0.0) diff --git a/rlberry/wrappers/tests/old_env/old_pendulum.py b/rlberry/wrappers/tests/old_env/old_pendulum.py index 1ce1151fe..7481f2f2d 100644 --- a/rlberry/wrappers/tests/old_env/old_pendulum.py +++ b/rlberry/wrappers/tests/old_env/old_pendulum.py @@ -82,9 +82,7 @@ def step(self, action): action = np.clip(action, -self.max_torque, self.max_torque)[0] self.last_action = action # for rendering - costs = ( - angle_normalize(theta) ** 2 + 0.1 * thetadot**2 + 0.001 * (action**2) - ) + costs = angle_normalize(theta) ** 2 + 0.1 * thetadot**2 + 0.001 * (action**2) # compute the next state after action newthetadot = ( diff --git a/scripts/fetch_contributors.py b/scripts/fetch_contributors.py index e89d347f7..e40ce976d 100644 --- a/scripts/fetch_contributors.py +++ b/scripts/fetch_contributors.py @@ -4,6 +4,7 @@ The table should be updated for each new inclusion in the teams. Generating the table requires admin rights. """ + import requests import time from pathlib import Path