diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5bcfcfb9..2cce837f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,14 @@ --- repos: - repo: https://github.com/codespell-project/codespell - rev: v2.2.5 + rev: v2.3.0 hooks: - id: codespell args: - --ignore-words-list=null exclude: docs/ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.2.1 + rev: v0.6.3 hooks: - id: ruff args: [ --fix ] diff --git a/PyFlyt/core/__init__.py b/PyFlyt/core/__init__.py index e79803f9..76346815 100644 --- a/PyFlyt/core/__init__.py +++ b/PyFlyt/core/__init__.py @@ -1,3 +1,4 @@ """Class implementations for creating custom UAVs in the PyBullet simulation environment.""" + from .aviary import Aviary from .utils.load_objs import loadOBJ, obj_collision, obj_visual diff --git a/PyFlyt/core/abstractions/__init__.py b/PyFlyt/core/abstractions/__init__.py index 70f87c29..ec1273ae 100644 --- a/PyFlyt/core/abstractions/__init__.py +++ b/PyFlyt/core/abstractions/__init__.py @@ -1,4 +1,5 @@ """Abstractions for PyFlyt drones.""" + from .base_controller import ControlClass from .base_drone import DroneClass from .base_wind_field import WindFieldClass diff --git a/PyFlyt/core/abstractions/base_controller.py b/PyFlyt/core/abstractions/base_controller.py index 0ef49dec..24bd6006 100644 --- a/PyFlyt/core/abstractions/base_controller.py +++ b/PyFlyt/core/abstractions/base_controller.py @@ -1,4 +1,5 @@ """Defines a basic controller class to inherit from when building custom controllers.""" + from abc import ABC, abstractmethod import numpy as np diff --git a/PyFlyt/core/abstractions/base_drone.py b/PyFlyt/core/abstractions/base_drone.py index 48f8b06a..df1cf7e7 100644 --- a/PyFlyt/core/abstractions/base_drone.py +++ b/PyFlyt/core/abstractions/base_drone.py @@ -1,4 +1,5 @@ """Basic Drone class for all drone models to inherit from.""" + from __future__ import annotations import os diff --git a/PyFlyt/core/abstractions/base_wind_field.py b/PyFlyt/core/abstractions/base_wind_field.py index d77bfae5..ab8f697c 100644 --- a/PyFlyt/core/abstractions/base_wind_field.py +++ b/PyFlyt/core/abstractions/base_wind_field.py @@ -1,4 +1,5 @@ """Defines a basic wind field class to inherit from when implementing custom wind field models.""" + from __future__ import annotations from abc import ABC, abstractmethod diff --git a/PyFlyt/core/abstractions/boosters.py b/PyFlyt/core/abstractions/boosters.py index 561f0c39..98703b9b 100644 --- a/PyFlyt/core/abstractions/boosters.py +++ b/PyFlyt/core/abstractions/boosters.py @@ -1,4 +1,5 @@ """A component to simulate an array of boosters on vehicle.""" + from __future__ import annotations import warnings diff --git a/PyFlyt/core/abstractions/boring_bodies.py b/PyFlyt/core/abstractions/boring_bodies.py index 443d45f1..3fbb6f60 100644 --- a/PyFlyt/core/abstractions/boring_bodies.py +++ b/PyFlyt/core/abstractions/boring_bodies.py @@ -1,4 +1,5 @@ """A component to simulate bodies moving through the air.""" + from __future__ import annotations from typing import Sequence diff --git a/PyFlyt/core/abstractions/camera.py b/PyFlyt/core/abstractions/camera.py index 52bd7252..e0efb5d1 100644 --- a/PyFlyt/core/abstractions/camera.py +++ b/PyFlyt/core/abstractions/camera.py @@ -1,4 +1,5 @@ """A component to simulate a camera on a vehicle.""" + from __future__ import annotations import math diff --git a/PyFlyt/core/abstractions/gimbals.py b/PyFlyt/core/abstractions/gimbals.py index f5f04b1d..b2fdebed 100644 --- a/PyFlyt/core/abstractions/gimbals.py +++ b/PyFlyt/core/abstractions/gimbals.py @@ -1,4 +1,5 @@ """A component to simulate an array of gimbals on vehicle.""" + from __future__ import annotations import warnings diff --git a/PyFlyt/core/abstractions/lifting_surfaces.py b/PyFlyt/core/abstractions/lifting_surfaces.py index af39b366..f0ad01ee 100644 --- a/PyFlyt/core/abstractions/lifting_surfaces.py +++ b/PyFlyt/core/abstractions/lifting_surfaces.py @@ -1,4 +1,5 @@ """A component to simulate lifting surfaces vehicle.""" + from __future__ import annotations import warnings diff --git a/PyFlyt/core/abstractions/motors.py b/PyFlyt/core/abstractions/motors.py index eae4bb4b..9483d9e2 100644 --- a/PyFlyt/core/abstractions/motors.py +++ b/PyFlyt/core/abstractions/motors.py @@ -1,4 +1,5 @@ """A component to simulate an array of electric propeller motors on vehicle.""" + from __future__ import annotations import warnings diff --git a/PyFlyt/core/abstractions/pid.py b/PyFlyt/core/abstractions/pid.py index db45369b..3455c123 100644 --- a/PyFlyt/core/abstractions/pid.py +++ b/PyFlyt/core/abstractions/pid.py @@ -1,4 +1,5 @@ """A simple class implementing the PID algorithm that works on numpy arrays.""" + import numba as nb import numpy as np diff --git a/PyFlyt/core/aviary.py b/PyFlyt/core/aviary.py index a487e228..31b8bed5 100644 --- a/PyFlyt/core/aviary.py +++ b/PyFlyt/core/aviary.py @@ -1,4 +1,5 @@ """The Aviary class, the core of how PyFlyt handles UAVs in the PyBullet simulation environment.""" + from __future__ import annotations import time diff --git a/PyFlyt/core/drones/__init__.py b/PyFlyt/core/drones/__init__.py index 0e07c7c2..275689b4 100644 --- a/PyFlyt/core/drones/__init__.py +++ b/PyFlyt/core/drones/__init__.py @@ -1,4 +1,5 @@ """Implementations of default drone models.""" + from .fixedwing import Fixedwing from .quadx import QuadX from .rocket import Rocket diff --git a/PyFlyt/core/drones/fixedwing.py b/PyFlyt/core/drones/fixedwing.py index e18040af..7348992c 100644 --- a/PyFlyt/core/drones/fixedwing.py +++ b/PyFlyt/core/drones/fixedwing.py @@ -1,4 +1,5 @@ """Implementation of a Fixedwing UAV.""" + from __future__ import annotations import numpy as np diff --git a/PyFlyt/core/drones/quadx.py b/PyFlyt/core/drones/quadx.py index cfc44363..95ad404b 100644 --- a/PyFlyt/core/drones/quadx.py +++ b/PyFlyt/core/drones/quadx.py @@ -1,4 +1,5 @@ """Implementation of a CrazyFlie 2.x UAV.""" + from __future__ import annotations import math diff --git a/PyFlyt/core/drones/rocket.py b/PyFlyt/core/drones/rocket.py index 8ba46398..7dee7fac 100644 --- a/PyFlyt/core/drones/rocket.py +++ b/PyFlyt/core/drones/rocket.py @@ -1,4 +1,5 @@ """Implementation of a 1:10 scale SpaceX Rocket UAV.""" + from __future__ import annotations import numpy as np diff --git a/PyFlyt/core/utils/compile_helpers.py b/PyFlyt/core/utils/compile_helpers.py index a05d827d..26e954a5 100644 --- a/PyFlyt/core/utils/compile_helpers.py +++ b/PyFlyt/core/utils/compile_helpers.py @@ -1,4 +1,5 @@ """Common checks.""" + import warnings from typing import Callable diff --git a/PyFlyt/core/utils/load_objs.py b/PyFlyt/core/utils/load_objs.py index c7412112..da0d49f7 100644 --- a/PyFlyt/core/utils/load_objs.py +++ b/PyFlyt/core/utils/load_objs.py @@ -1,4 +1,5 @@ """Convenience function to load an obj into the pybullet environment.""" + from __future__ import annotations import numpy as np diff --git a/PyFlyt/gym_envs/__init__.py b/PyFlyt/gym_envs/__init__.py index 727ceeee..b131f0ce 100644 --- a/PyFlyt/gym_envs/__init__.py +++ b/PyFlyt/gym_envs/__init__.py @@ -1,4 +1,5 @@ """Registers PyFlyt environments into Gymnasium.""" + from gymnasium.envs.registration import register from PyFlyt.gym_envs.utils.flatten_waypoint_env import FlattenWaypointEnv diff --git a/PyFlyt/gym_envs/fixedwing_envs/fixedwing_base_env.py b/PyFlyt/gym_envs/fixedwing_envs/fixedwing_base_env.py index caae3c3f..e30aff99 100644 --- a/PyFlyt/gym_envs/fixedwing_envs/fixedwing_base_env.py +++ b/PyFlyt/gym_envs/fixedwing_envs/fixedwing_base_env.py @@ -1,4 +1,5 @@ """Base PyFlyt Environment for the Fixedwing model using the Gymnasim API.""" + from __future__ import annotations from typing import Any, Literal @@ -295,7 +296,7 @@ def step(self, action: np.ndarray) -> tuple[Any, float, bool, bool, dict]: return self.state, self.reward, self.termination, self.truncation, self.info def render(self) -> np.ndarray: - """render.""" + """Render.""" check_numpy() if self.render_mode is None: raise ValueError( diff --git a/PyFlyt/gym_envs/fixedwing_envs/fixedwing_waypoints_env.py b/PyFlyt/gym_envs/fixedwing_envs/fixedwing_waypoints_env.py index 44a02488..86ae8e37 100644 --- a/PyFlyt/gym_envs/fixedwing_envs/fixedwing_waypoints_env.py +++ b/PyFlyt/gym_envs/fixedwing_envs/fixedwing_waypoints_env.py @@ -1,4 +1,5 @@ """Fixedwing Waypoints Environment.""" + from __future__ import annotations from typing import Any, Literal @@ -171,7 +172,7 @@ def compute_state(self) -> None: self.state: dict[Literal["attitude", "target_deltas"], np.ndarray] = new_state def compute_term_trunc_reward(self) -> None: - """Computes the termination, trunction, and reward of the current timestep.""" + """Computes the termination, truncation, and reward of the current timestep.""" super().compute_base_term_trunc_reward() # bonus reward if we are not sparse diff --git a/PyFlyt/gym_envs/quadx_envs/quadx_base_env.py b/PyFlyt/gym_envs/quadx_envs/quadx_base_env.py index fc406705..e54de615 100644 --- a/PyFlyt/gym_envs/quadx_envs/quadx_base_env.py +++ b/PyFlyt/gym_envs/quadx_envs/quadx_base_env.py @@ -1,4 +1,5 @@ """Base PyFlyt Environment for the QuadX model using the Gymnasim API.""" + from __future__ import annotations from typing import Any, Literal @@ -305,7 +306,7 @@ def step(self, action: np.ndarray) -> tuple[Any, float, bool, bool, dict[str, An return self.state, self.reward, self.termination, self.truncation, self.info def render(self) -> np.ndarray: - """render.""" + """Render.""" check_numpy() if self.render_mode is None: raise ValueError( diff --git a/PyFlyt/gym_envs/quadx_envs/quadx_gates_env.py b/PyFlyt/gym_envs/quadx_envs/quadx_gates_env.py index 3aebfa22..b2b6c330 100644 --- a/PyFlyt/gym_envs/quadx_envs/quadx_gates_env.py +++ b/PyFlyt/gym_envs/quadx_envs/quadx_gates_env.py @@ -1,4 +1,5 @@ """QuadX Gates Environment.""" + from __future__ import annotations import copy diff --git a/PyFlyt/gym_envs/quadx_envs/quadx_hover_env.py b/PyFlyt/gym_envs/quadx_envs/quadx_hover_env.py index dd805b7d..081be0a0 100644 --- a/PyFlyt/gym_envs/quadx_envs/quadx_hover_env.py +++ b/PyFlyt/gym_envs/quadx_envs/quadx_hover_env.py @@ -1,4 +1,5 @@ """QuadX Hover Environment.""" + from __future__ import annotations from typing import Any, Literal diff --git a/PyFlyt/gym_envs/quadx_envs/quadx_pole_balance_env.py b/PyFlyt/gym_envs/quadx_envs/quadx_pole_balance_env.py index 6d5aaf28..5799fefe 100644 --- a/PyFlyt/gym_envs/quadx_envs/quadx_pole_balance_env.py +++ b/PyFlyt/gym_envs/quadx_envs/quadx_pole_balance_env.py @@ -1,4 +1,5 @@ """QuadX Pole Balance Environment.""" + from __future__ import annotations from typing import Any, Literal diff --git a/PyFlyt/gym_envs/quadx_envs/quadx_pole_waypoints_env.py b/PyFlyt/gym_envs/quadx_envs/quadx_pole_waypoints_env.py index 7391d762..33a87c5a 100644 --- a/PyFlyt/gym_envs/quadx_envs/quadx_pole_waypoints_env.py +++ b/PyFlyt/gym_envs/quadx_envs/quadx_pole_waypoints_env.py @@ -1,4 +1,5 @@ """QuadX Pole Waypoints Environment.""" + from __future__ import annotations from typing import Any, Literal diff --git a/PyFlyt/gym_envs/quadx_envs/quadx_waypoints_env.py b/PyFlyt/gym_envs/quadx_envs/quadx_waypoints_env.py index dd565da7..e40b2156 100644 --- a/PyFlyt/gym_envs/quadx_envs/quadx_waypoints_env.py +++ b/PyFlyt/gym_envs/quadx_envs/quadx_waypoints_env.py @@ -1,4 +1,5 @@ """QuadX Waypoints Environment.""" + from __future__ import annotations from typing import Any, Literal @@ -177,7 +178,7 @@ def compute_state(self) -> None: self.state: dict[Literal["attitude", "target_deltas"], np.ndarray] = new_state def compute_term_trunc_reward(self) -> None: - """Computes the termination, trunction, and reward of the current timestep.""" + """Computes the termination, truncation, and reward of the current timestep.""" super().compute_base_term_trunc_reward() # bonus reward if we are not sparse diff --git a/PyFlyt/gym_envs/rocket_envs/rocket_base_env.py b/PyFlyt/gym_envs/rocket_envs/rocket_base_env.py index eef15702..9448218b 100644 --- a/PyFlyt/gym_envs/rocket_envs/rocket_base_env.py +++ b/PyFlyt/gym_envs/rocket_envs/rocket_base_env.py @@ -1,4 +1,5 @@ """Base PyFlyt Environment for the Rocket model using the Gymnasim API.""" + from __future__ import annotations from typing import Any, Literal @@ -348,7 +349,7 @@ def step(self, action: np.ndarray): return self.state, self.reward, self.termination, self.truncation, self.info def render(self): - """render.""" + """Render.""" check_numpy() if self.render_mode is None: raise ValueError( diff --git a/PyFlyt/gym_envs/rocket_envs/rocket_landing_env.py b/PyFlyt/gym_envs/rocket_envs/rocket_landing_env.py index bfe96d36..f29b1090 100644 --- a/PyFlyt/gym_envs/rocket_envs/rocket_landing_env.py +++ b/PyFlyt/gym_envs/rocket_envs/rocket_landing_env.py @@ -1,4 +1,5 @@ """Rocket Landing Environment.""" + from __future__ import annotations import os diff --git a/PyFlyt/gym_envs/utils/flatten_waypoint_env.py b/PyFlyt/gym_envs/utils/flatten_waypoint_env.py index 665b3b4a..1e094f9c 100644 --- a/PyFlyt/gym_envs/utils/flatten_waypoint_env.py +++ b/PyFlyt/gym_envs/utils/flatten_waypoint_env.py @@ -1,4 +1,5 @@ """Wrapper class for flattening the waypoint envs to use homogeneous observation spaces.""" + from __future__ import annotations import numpy as np diff --git a/PyFlyt/gym_envs/utils/waypoint_handler.py b/PyFlyt/gym_envs/utils/waypoint_handler.py index cb40deca..522458f7 100644 --- a/PyFlyt/gym_envs/utils/waypoint_handler.py +++ b/PyFlyt/gym_envs/utils/waypoint_handler.py @@ -1,4 +1,5 @@ """Handler for Waypoints in the environments.""" + from __future__ import annotations import math diff --git a/PyFlyt/pz_envs/__init__.py b/PyFlyt/pz_envs/__init__.py index 2686246d..969d12df 100644 --- a/PyFlyt/pz_envs/__init__.py +++ b/PyFlyt/pz_envs/__init__.py @@ -1,3 +1,4 @@ """Imports all PZ envs.""" + from .fixedwing_envs.ma_fixedwing_dogfight_env import MAFixedwingDogfightEnv from .quadx_envs.ma_quadx_hover_env import MAQuadXHoverEnv diff --git a/PyFlyt/pz_envs/fixedwing_envs/ma_fixedwing_base_env.py b/PyFlyt/pz_envs/fixedwing_envs/ma_fixedwing_base_env.py index b11838dd..7e3191c0 100644 --- a/PyFlyt/pz_envs/fixedwing_envs/ma_fixedwing_base_env.py +++ b/PyFlyt/pz_envs/fixedwing_envs/ma_fixedwing_base_env.py @@ -1,4 +1,5 @@ """Base Multiagent Fixedwing Environment.""" + from __future__ import annotations from copy import deepcopy @@ -152,7 +153,7 @@ def action_space(self, agent: Any = None) -> spaces.Box: return self._action_space def close(self) -> None: - """close.""" + """Close.""" if hasattr(self, "aviary"): self.aviary.disconnect() diff --git a/PyFlyt/pz_envs/fixedwing_envs/ma_fixedwing_dogfight_env.py b/PyFlyt/pz_envs/fixedwing_envs/ma_fixedwing_dogfight_env.py index 348a832f..4ec470a4 100644 --- a/PyFlyt/pz_envs/fixedwing_envs/ma_fixedwing_dogfight_env.py +++ b/PyFlyt/pz_envs/fixedwing_envs/ma_fixedwing_dogfight_env.py @@ -1,4 +1,5 @@ """Multiagent Fixedwing Dogfighting Environment.""" + from __future__ import annotations from typing import Any diff --git a/PyFlyt/pz_envs/quadx_envs/ma_quadx_base_env.py b/PyFlyt/pz_envs/quadx_envs/ma_quadx_base_env.py index 07310011..1015cb77 100644 --- a/PyFlyt/pz_envs/quadx_envs/ma_quadx_base_env.py +++ b/PyFlyt/pz_envs/quadx_envs/ma_quadx_base_env.py @@ -1,4 +1,5 @@ """Base Multiagent QuadX Environment.""" + from __future__ import annotations from copy import deepcopy @@ -179,7 +180,7 @@ def action_space(self, agent: Any = None) -> spaces.Box: return self._action_space def close(self) -> None: - """close.""" + """Close.""" if hasattr(self, "aviary"): self.aviary.disconnect() diff --git a/PyFlyt/pz_envs/quadx_envs/ma_quadx_hover_env.py b/PyFlyt/pz_envs/quadx_envs/ma_quadx_hover_env.py index 64569daf..cbe290cf 100644 --- a/PyFlyt/pz_envs/quadx_envs/ma_quadx_hover_env.py +++ b/PyFlyt/pz_envs/quadx_envs/ma_quadx_hover_env.py @@ -1,4 +1,5 @@ """Multiagent QuadX Hover Environment.""" + from __future__ import annotations from typing import Any diff --git a/examples/core/01_single_drone.py b/examples/core/01_single_drone.py index 0d3791bd..d342f632 100644 --- a/examples/core/01_single_drone.py +++ b/examples/core/01_single_drone.py @@ -1,4 +1,5 @@ """Spawn a single drone on x=0, y=0, z=1, with 0 rpy.""" + import numpy as np from PyFlyt.core import Aviary diff --git a/examples/core/02_multi_drone.py b/examples/core/02_multi_drone.py index 93f012e0..d13e8757 100644 --- a/examples/core/02_multi_drone.py +++ b/examples/core/02_multi_drone.py @@ -1,4 +1,5 @@ """Spawns three drones, then sets all drones to have different control looprates.""" + import numpy as np from PyFlyt.core import Aviary diff --git a/examples/core/03_control.py b/examples/core/03_control.py index ec201ff4..f2843709 100644 --- a/examples/core/03_control.py +++ b/examples/core/03_control.py @@ -1,4 +1,5 @@ """Spawn a single drone, then command it to go to two setpoints consecutively, and plots the xyz output.""" + import matplotlib.pyplot as plt import numpy as np diff --git a/examples/core/04_camera.py b/examples/core/04_camera.py index aa00ac8b..ae879a8a 100644 --- a/examples/core/04_camera.py +++ b/examples/core/04_camera.py @@ -1,4 +1,5 @@ """Spawn a single drone and get its camera image.""" + import matplotlib.pyplot as plt import numpy as np diff --git a/examples/core/05_custom_controller.py b/examples/core/05_custom_controller.py index e2f12a99..60177e02 100644 --- a/examples/core/05_custom_controller.py +++ b/examples/core/05_custom_controller.py @@ -1,4 +1,5 @@ """Implement a controller that only wants the drone to be at x=1, y=1, z=1, while constantly spinning at yawrate=0.5, building off mode 6.""" + import numpy as np from PyFlyt.core import Aviary diff --git a/examples/core/06_spawning_objects.py b/examples/core/06_spawning_objects.py index 53a8d774..b727d5e0 100644 --- a/examples/core/06_spawning_objects.py +++ b/examples/core/06_spawning_objects.py @@ -1,4 +1,5 @@ """Spawn a duck object above the drone.""" + import numpy as np from PyFlyt.core import Aviary, loadOBJ, obj_collision, obj_visual diff --git a/examples/core/07_custom_uav.py b/examples/core/07_custom_uav.py index cbb38188..4375d556 100644 --- a/examples/core/07_custom_uav.py +++ b/examples/core/07_custom_uav.py @@ -1,4 +1,5 @@ """Implements a custom UAV in the Aviary.""" + import numpy as np from custom_uavs.rocket_brick import RocketBrick diff --git a/examples/core/08_mixed_drones.py b/examples/core/08_mixed_drones.py index 28ce45e0..ac7d27c6 100644 --- a/examples/core/08_mixed_drones.py +++ b/examples/core/08_mixed_drones.py @@ -1,4 +1,5 @@ """Spawns three different types of drones, then gets all their states.""" + import numpy as np from PyFlyt.core import Aviary diff --git a/examples/core/09_simple_wind.py b/examples/core/09_simple_wind.py index 45fd7a9d..c2900a71 100644 --- a/examples/core/09_simple_wind.py +++ b/examples/core/09_simple_wind.py @@ -1,4 +1,5 @@ """Implements a simple time invariant, stateless wind model.""" + import numpy as np from PyFlyt.core import Aviary diff --git a/examples/core/10_custom_wind.py b/examples/core/10_custom_wind.py index c4ee8a2c..7071f193 100644 --- a/examples/core/10_custom_wind.py +++ b/examples/core/10_custom_wind.py @@ -1,4 +1,5 @@ """Implements a custom stateful wind model.""" + import numpy as np from PyFlyt.core import Aviary diff --git a/examples/core/custom_uavs/rocket_brick.py b/examples/core/custom_uavs/rocket_brick.py index 88026b92..78dfe020 100644 --- a/examples/core/custom_uavs/rocket_brick.py +++ b/examples/core/custom_uavs/rocket_brick.py @@ -1,4 +1,5 @@ """Implements a custom brick with a booster attached.""" + from __future__ import annotations import os diff --git a/tests/test_core.py b/tests/test_core.py index 504872a7..e1a4afaf 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,4 +1,5 @@ """Tests the the core API functionality.""" + from __future__ import annotations import numpy as np diff --git a/tests/test_gym_envs.py b/tests/test_gym_envs.py index eab298c6..d193306a 100644 --- a/tests/test_gym_envs.py +++ b/tests/test_gym_envs.py @@ -1,4 +1,5 @@ """Tests the API compatibility of all PyFlyt Gymnasium Envs.""" + import itertools import warnings diff --git a/tests/test_pz_envs.py b/tests/test_pz_envs.py index 6db4af4c..58342cbf 100644 --- a/tests/test_pz_envs.py +++ b/tests/test_pz_envs.py @@ -1,4 +1,5 @@ """Tests the API compatibility of all PyFlyt Pettingzoo Environments.""" + from __future__ import annotations import warnings