Skip to content

Commit

Permalink
pre-commit autoupdate (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudo-rnd-thoughts authored Jan 12, 2024
1 parent 4373191 commit bdb182f
Show file tree
Hide file tree
Showing 12 changed files with 7 additions and 25 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
repos:
- repo: https://github.com/python/black
rev: 22.3.0
rev: 23.12.1
hooks:
- id: black
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
rev: v2.2.6
hooks:
- id: codespell
args:
- --ignore-words-list=linz
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 7.0.0
hooks:
- id: flake8
args:
Expand All @@ -22,7 +22,7 @@ repos:
- --show-source
- --statistics
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]
Expand All @@ -36,7 +36,7 @@ repos:
# - --convention=google
# additional_dependencies: ["toml"]
- repo: https://github.com/asottile/pyupgrade
rev: v2.32.0
rev: v3.15.0
hooks:
- id: pyupgrade
args: ["--py37-plus"]
Expand Down
1 change: 0 additions & 1 deletion docs/_scripts/gen_gifs.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
state, info = env.reset()
terminated, truncated = False, False
while not (terminated or truncated) and len(frames) <= LENGTH:

frame = env.render()
frames.append(Image.fromarray(frame))
action = env.action_space.sample()
Expand Down
2 changes: 1 addition & 1 deletion docs/content/create_env_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class SimpleEnv(MiniGridEnv):
# Generate the surrounding walls
self.grid.wall_rect(0, 0, width, height)

# Generate verical separation wall
# Generate vertical separation wall
for i in range(0, height):
self.grid.set(5, i, Wall())

Expand Down
3 changes: 0 additions & 3 deletions minigrid/core/mission.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ def __repr__(self) -> str:
def __eq__(self, other) -> bool:
"""Check whether ``other`` is equivalent to this instance."""
if isinstance(other, MissionSpace):

# Check that place holder lists are the same
if self.ordered_placeholders is not None:
# Check length
Expand All @@ -189,10 +188,8 @@ def __eq__(self, other) -> bool:
other_mission = other.mission_func(*test_placeholders)
return mission == other_mission
else:

# Check that other is also None
if other.ordered_placeholders is None:

# Check mission string is the same
mission = self.mission_func()
other_mission = other.mission_func()
Expand Down
1 change: 0 additions & 1 deletion minigrid/envs/babyai/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ class FindObjS5(RoomGridLevel):
"""

def __init__(self, room_size=5, max_steps: int | None = None, **kwargs):

if max_steps is None:
max_steps = 20 * room_size**2

Expand Down
1 change: 0 additions & 1 deletion minigrid/envs/fourrooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def _gen_grid(self, width, height):

# For each row of rooms
for j in range(0, 2):

# For each column
for i in range(0, 2):
xL = i * room_w
Expand Down
1 change: 0 additions & 1 deletion minigrid/envs/gotoobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class GoToObjectEnv(MiniGridEnv):
"""

def __init__(self, size=6, numObjs=2, max_steps: int | None = None, **kwargs):

self.numObjs = numObjs
self.size = size
# Types of objects to be generated
Expand Down
2 changes: 0 additions & 2 deletions minigrid/envs/multiroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ def _gen_grid(self, width, height):

# For each room
for idx, room in enumerate(roomList):

topX, topY = room.top
sizeX, sizeY = room.size

Expand Down Expand Up @@ -242,7 +241,6 @@ def _placeRoom(self, numLeft, roomList, minSz, maxSz, entryDoorWall, entryDoorPo

# Try placing the next room
for i in range(0, 8):

# Pick which wall to place the out door on
wallSet = {0, 1, 2, 3}
wallSet.remove(entryDoorWall)
Expand Down
1 change: 0 additions & 1 deletion minigrid/envs/playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def _gen_grid(self, width, height):

# For each row of rooms
for j in range(0, 3):

# For each column
for i in range(0, 3):
xL = i * roomW
Expand Down
7 changes: 0 additions & 7 deletions minigrid/envs/wfc/graphtransforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class GraphTransforms:

@staticmethod
def minigrid_to_bitmap(grids):

layout = grids[..., 0]
bitmap = np.zeros_like(layout)
bitmap[layout == 2] = 1
Expand Down Expand Up @@ -97,7 +96,6 @@ def minigrid_to_dense_graph(
def minigrid_layout_to_dense_graph(
layouts: np.ndarray, remove_border=True, node_attr=None, edge_config=None
) -> tuple[list[nx.Graph], dict[str, list[nx.Graph]]]:

assert (
layouts.ndim == 3
), f"Wrong dimensions for minigrid layout, expected 3 dimensions, got {layouts.ndim}."
Expand Down Expand Up @@ -165,7 +163,6 @@ def features_to_dense_graph(
dim_grid: tuple,
edge_config: dict[str, EdgeDescriptor] = None,
) -> tuple[list[nx.Graph], dict[str, list[nx.Graph]]]:

graphs = []
edge_graphs = defaultdict(list)
for m in range(features[list(features.keys())[0]].shape[0]):
Expand All @@ -191,7 +188,6 @@ def features_to_dense_graph(
def graph_features_to_minigrid(
graph_features: dict[str, np.ndarray], shape: tuple[int, int], padding=1
) -> np.ndarray:

features = graph_features.copy()
node_attributes = list(features.keys())

Expand Down Expand Up @@ -285,7 +281,6 @@ def graph_features_to_minigrid(
def get_node_features(
graph: nx.Graph, pattern_shape, node_attributes: list[str] = None, reshape=True
) -> tuple[np.ndarray, list[str]]:

if node_attributes is None:
# Get node attributes from some node
node_attributes = list(next(iter(graph.nodes.data()))[1].keys())
Expand Down Expand Up @@ -313,7 +308,6 @@ def get_node_features(
def dense_graph_to_minigrid(
graph: nx.Graph, shape: tuple[int, int], padding=1
) -> np.ndarray:

pattern_shape = (shape[0] - 2 * padding, shape[1] - 2 * padding)
features, node_attributes = GraphTransforms.get_node_features(
graph, pattern_shape, node_attributes=None
Expand All @@ -340,7 +334,6 @@ def get_edge_layers(
node_attr: list[str],
dim_grid: tuple[int, int],
) -> dict[str, nx.Graph]:

navigable_nodes = ["empty", "start", "goal", "moss"]
non_navigable_nodes = ["wall", "lava"]
assert all([isinstance(n, tuple) for n in graph.nodes])
Expand Down
1 change: 0 additions & 1 deletion tests/test_envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ def test_interactive_mode(env_id):


def test_mission_space():

# Test placeholders
mission_space = MissionSpace(
mission_func=lambda color, obj_type: f"Get the {color} {obj_type}.",
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def assert_equals(a, b, prefix=None):
b: second data structure
prefix: prefix for failed assertion message for types and dicts
"""
assert type(a) == type(b), f"{prefix}Differing types: {a} and {b}"
assert type(a) is type(b), f"{prefix}Differing types: {a} and {b}"
if isinstance(a, dict):
assert list(a.keys()) == list(b.keys()), f"{prefix}Key sets differ: {a} and {b}"

Expand Down

0 comments on commit bdb182f

Please sign in to comment.