From a5473c07437439b1875ec7bd41a4a128ce7d3566 Mon Sep 17 00:00:00 2001 From: Maximilian Naumann Date: Tue, 16 Jan 2024 23:25:13 +0100 Subject: [PATCH] Add and run isort --- .github/workflows/ci.yml | 3 +++ pyproject.toml | 6 +++++- scripts/run_a_star.py | 2 +- .../graph_search/a_star.py | 4 ++-- .../utils/grid_plotting.py | 1 + tests/test_a_star.py | 2 +- tests/test_mdp.py | 6 +++--- tests/utils/test_grid_plotting.py | 8 ++++---- 8 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a05d1f9..4f378e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,9 @@ jobs: - name: run black run: black --check . + - name: run isort + run: isort . + - name: run pylint for mdp folder run: pylint src/behavior_generation_lecture_python/mdp --errors-only diff --git a/pyproject.toml b/pyproject.toml index b8c06da..99f88cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,8 @@ dev = [ "pytest", "pytest-cov>=3.0.0", "pylint", - "mypy" + "mypy", + "isort" ] docs = [ "mkdocs-material", @@ -45,3 +46,6 @@ docs = [ [build-system] requires = ["setuptools>=64.0.0", "wheel", "pip>=21.3.0"] build-backend = "setuptools.build_meta" + +[tool.isort] +profile = "black" diff --git a/scripts/run_a_star.py b/scripts/run_a_star.py index 29d9031..82349da 100644 --- a/scripts/run_a_star.py +++ b/scripts/run_a_star.py @@ -1,6 +1,6 @@ import numpy as np -from behavior_generation_lecture_python.graph_search.a_star import Node, Graph +from behavior_generation_lecture_python.graph_search.a_star import Graph, Node def main(): diff --git a/src/behavior_generation_lecture_python/graph_search/a_star.py b/src/behavior_generation_lecture_python/graph_search/a_star.py index 16b9920..598ac37 100644 --- a/src/behavior_generation_lecture_python/graph_search/a_star.py +++ b/src/behavior_generation_lecture_python/graph_search/a_star.py @@ -1,10 +1,10 @@ from __future__ import annotations +from typing import Dict, List, Set + import matplotlib.pyplot as plt import numpy as np -from typing import Dict, List, Set - class Node: def __init__( diff --git a/src/behavior_generation_lecture_python/utils/grid_plotting.py b/src/behavior_generation_lecture_python/utils/grid_plotting.py index 023c378..37262bb 100644 --- a/src/behavior_generation_lecture_python/utils/grid_plotting.py +++ b/src/behavior_generation_lecture_python/utils/grid_plotting.py @@ -1,4 +1,5 @@ from collections import defaultdict + import matplotlib.pyplot as plt import numpy as np diff --git a/tests/test_a_star.py b/tests/test_a_star.py index d5fa657..80debb5 100644 --- a/tests/test_a_star.py +++ b/tests/test_a_star.py @@ -1,7 +1,7 @@ import matplotlib import numpy as np -from behavior_generation_lecture_python.graph_search.a_star import Node, Graph +from behavior_generation_lecture_python.graph_search.a_star import Graph, Node def test_example_graph(): diff --git a/tests/test_mdp.py b/tests/test_mdp.py index f2da1fa..582026a 100644 --- a/tests/test_mdp.py +++ b/tests/test_mdp.py @@ -5,13 +5,13 @@ MDP, SIMPLE_MDP_DICT, GridMDP, + best_action_from_q_table, derive_policy, expected_utility_of_action, - value_iteration, - best_action_from_q_table, - random_action, greedy_value_estimate_for_state, q_learning, + random_action, + value_iteration, ) diff --git a/tests/utils/test_grid_plotting.py b/tests/utils/test_grid_plotting.py index 78a3fdc..a6f0bff 100644 --- a/tests/utils/test_grid_plotting.py +++ b/tests/utils/test_grid_plotting.py @@ -1,14 +1,14 @@ import matplotlib -from behavior_generation_lecture_python.utils.grid_plotting import ( - make_plot_grid_step_function, - make_plot_policy_step_function, -) from behavior_generation_lecture_python.mdp.mdp import ( GRID_MDP_DICT, GridMDP, derive_policy, ) +from behavior_generation_lecture_python.utils.grid_plotting import ( + make_plot_grid_step_function, + make_plot_policy_step_function, +) TRUE_UTILITY_GRID_MDP = { (0, 0): 0.705,