diff --git a/.github/workflows/cibuildwheel.yml b/.github/workflows/cibuildwheel.yml
index fe9ef7f78..b82f70e55 100644
--- a/.github/workflows/cibuildwheel.yml
+++ b/.github/workflows/cibuildwheel.yml
@@ -31,7 +31,7 @@ jobs:
with:
python-version: "3.12"
- name: Install dependencies
- run: pip install black==24.4.0 isort==5.13.2 jupyter-black==0.3.4
+ run: pip install ruff
- name: Run checks
run: ./scripts/ci/check_format.sh
diff --git a/container/perf-measurement/container_perf_test.py b/container/perf-measurement/container_perf_test.py
index 55788ccc1..efbe1c3a6 100644
--- a/container/perf-measurement/container_perf_test.py
+++ b/container/perf-measurement/container_perf_test.py
@@ -75,7 +75,7 @@ def build_jupedsim():
def run_test(test, args, build_dir, result_dir):
test_env = os.environ.copy()
test_env["PYTHONPATH"] = (
- f"/src/python_modules/jupedsim:/src/python_modules/jupedsim_visualizer:/build/lib"
+ "/src/python_modules/jupedsim:/src/python_modules/jupedsim_visualizer:/build/lib"
)
perf_data_file_name = f"{test}.perf.data"
diff --git a/examples/example1.py b/examples/example1.py
index 446bdb7c3..2fc3d40b1 100755
--- a/examples/example1.py
+++ b/examples/example1.py
@@ -5,9 +5,8 @@
import pathlib
import sys
-from shapely import GeometryCollection, Polygon
-
import jupedsim as jps
+from shapely import GeometryCollection, Polygon
def main():
diff --git a/examples/example2.py b/examples/example2.py
index 401bd451e..edd13fe7e 100755
--- a/examples/example2.py
+++ b/examples/example2.py
@@ -5,9 +5,8 @@
import pathlib
import sys
-from shapely import GeometryCollection, Polygon
-
import jupedsim as jps
+from shapely import GeometryCollection, Polygon
def main():
@@ -16,9 +15,7 @@ def main():
jps.set_warning_callback(lambda x: print(x))
jps.set_error_callback(lambda x: print(x))
- area = GeometryCollection(
- Polygon([(0, 0), (100, 0), (100, 100), (0, 100)])
- )
+ area = GeometryCollection(Polygon([(0, 0), (100, 0), (100, 100), (0, 100)]))
simulation = jps.Simulation(
model=jps.CollisionFreeSpeedModel(),
diff --git a/examples/example3.py b/examples/example3.py
index 73fd7530f..83912a01a 100755
--- a/examples/example3.py
+++ b/examples/example3.py
@@ -33,9 +33,7 @@ def main():
]
)
queue = simulation.get_stage(stage_id)
- exit = simulation.add_exit_stage(
- [(99, 40), (99, 60), (100, 60), (100, 40)]
- )
+ exit = simulation.add_exit_stage([(99, 40), (99, 60), (100, 60), (100, 40)])
journey = jps.JourneyDescription([stage_id, exit])
journey.set_transition_for_stage(
diff --git a/examples/example4.py b/examples/example4.py
index 763ab2f63..d8d2cc5d9 100755
--- a/examples/example4.py
+++ b/examples/example4.py
@@ -38,9 +38,7 @@ def main():
exit_left = simulation.add_exit_stage(
[(-24, -8), (-24, 8), (-23, 8), (-23, -8)]
)
- exit_top = simulation.add_exit_stage(
- [(-8, 24), (8, 24), (8, 23), (-8, 23)]
- )
+ exit_top = simulation.add_exit_stage([(-8, 24), (8, 24), (8, 23), (-8, 23)])
exit_right = simulation.add_exit_stage(
[(24, -8), (24, 8), (23, 8), (23, -8)]
)
diff --git a/examples/example5.py b/examples/example5.py
index 47524b1e6..f604aced0 100755
--- a/examples/example5.py
+++ b/examples/example5.py
@@ -36,9 +36,7 @@ def main():
),
)
- exit_top = simulation.add_exit_stage(
- [(-2, 24), (2, 24), (2, 25), (-2, 25)]
- )
+ exit_top = simulation.add_exit_stage([(-2, 24), (2, 24), (2, 25), (-2, 25)])
exit_right = simulation.add_exit_stage(
[(34, -2), (34, 2), (35, 2), (35, -2)]
)
diff --git a/examples/example6.py b/examples/example6.py
index b9124b309..f3e9eb923 100755
--- a/examples/example6.py
+++ b/examples/example6.py
@@ -6,9 +6,8 @@
import pathlib
import sys
-import shapely
-
import jupedsim as jps
+import shapely
def main():
diff --git a/notebooks/corner-SocialForce.ipynb b/notebooks/corner-SocialForce.ipynb
index 53cc7bd51..b0b2484a8 100644
--- a/notebooks/corner-SocialForce.ipynb
+++ b/notebooks/corner-SocialForce.ipynb
@@ -40,14 +40,12 @@
},
"outputs": [],
"source": [
- "from shapely import GeometryCollection, Polygon, to_wkt\n",
"import pathlib\n",
+ "\n",
"import jupedsim as jps\n",
"import pedpy\n",
- "import pandas as pd\n",
- "import numpy as np\n",
"from numpy.random import normal # normal distribution of free movement speed\n",
- "import matplotlib.pyplot as plt"
+ "from shapely import Polygon"
]
},
{
diff --git a/notebooks/corner.ipynb b/notebooks/corner.ipynb
index e6dde27ab..50703a7d7 100644
--- a/notebooks/corner.ipynb
+++ b/notebooks/corner.ipynb
@@ -42,14 +42,12 @@
},
"outputs": [],
"source": [
- "from shapely import GeometryCollection, Polygon, to_wkt\n",
"import pathlib\n",
+ "\n",
"import jupedsim as jps\n",
"import pedpy\n",
- "import pandas as pd\n",
- "import numpy as np\n",
"from numpy.random import normal # normal distribution of free movement speed\n",
- "import matplotlib.pyplot as plt"
+ "from shapely import Polygon"
]
},
{
diff --git a/notebooks/double-bottleneck.ipynb b/notebooks/double-bottleneck.ipynb
index 5b322a4ca..c7b101552 100644
--- a/notebooks/double-bottleneck.ipynb
+++ b/notebooks/double-bottleneck.ipynb
@@ -35,14 +35,14 @@
},
"outputs": [],
"source": [
- "from shapely import GeometryCollection, Polygon, to_wkt\n",
"import pathlib\n",
+ "\n",
"import jupedsim as jps\n",
- "from numpy.random import normal # normal distribution of free movement speed\n",
- "import pedpy\n",
+ "import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
- "import numpy as np\n",
- "import matplotlib.pyplot as plt"
+ "import pedpy\n",
+ "from numpy.random import normal # normal distribution of free movement speed\n",
+ "from shapely import GeometryCollection, Polygon"
]
},
{
@@ -548,9 +548,7 @@
"corridor_narrow = Polygon([(10, 4.6), (28, 4.6), (28, 5.4), (10, 5.4)])\n",
"area_narrow = GeometryCollection(corridor_narrow.union(room1.union(room2)))\n",
"walkable_area_narrow = pedpy.WalkableArea(area_narrow.geoms[0])\n",
- "pedpy.plot_walkable_area(walkable_area=walkable_area_narrow).set_aspect(\n",
- " \"equal\"\n",
- ")"
+ "pedpy.plot_walkable_area(walkable_area=walkable_area_narrow).set_aspect(\"equal\")"
]
},
{
@@ -633,9 +631,7 @@
"source": [
"from jupedsim.internal.notebook_utils import animate, read_sqlite_file\n",
"\n",
- "trajectory_data_narrow, walkable_area = read_sqlite_file(\n",
- " trajectory_file_narrow\n",
- ")\n",
+ "trajectory_data_narrow, walkable_area = read_sqlite_file(trajectory_file_narrow)\n",
"animate(trajectory_data_narrow, walkable_area)"
]
},
diff --git a/notebooks/getting_started.ipynb b/notebooks/getting_started.ipynb
index a3ff36643..48c3aabbc 100644
--- a/notebooks/getting_started.ipynb
+++ b/notebooks/getting_started.ipynb
@@ -137,7 +137,7 @@
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
- "from pedpy import plot_walkable_area, WalkableArea\n",
+ "from pedpy import WalkableArea, plot_walkable_area\n",
"\n",
"plot_walkable_area(walkable_area=WalkableArea(geometry)).set_aspect(\"equal\")\n",
"plt.show()"
@@ -188,7 +188,7 @@
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
- "from pedpy import plot_measurement_setup, WalkableArea, MeasurementArea\n",
+ "from pedpy import MeasurementArea, WalkableArea, plot_measurement_setup\n",
"\n",
"# We will use PedPy's plotting functionality, but it has no concept of exits\n",
"# hence we will show the exit as measurement area\n",
@@ -236,9 +236,7 @@
" header=None,\n",
" names=[\"id\", \"frame\", \"x\", \"y\", \"z\"],\n",
")\n",
- "start_positions = experiment_data[experiment_data.frame == 0][\n",
- " [\"x\", \"y\"]\n",
- "].values"
+ "start_positions = experiment_data[experiment_data.frame == 0][[\"x\", \"y\"]].values"
]
},
{
@@ -263,9 +261,10 @@
"metadata": {},
"outputs": [],
"source": [
- "import jupedsim as jps\n",
"import pathlib\n",
"\n",
+ "import jupedsim as jps\n",
+ "\n",
"trajectory_file = \"bottleneck_cfsm.sqlite\"\n",
"simulation_cfsm = jps.Simulation(\n",
" model=jps.CollisionFreeSpeedModel(),\n",
@@ -429,9 +428,10 @@
},
"outputs": [],
"source": [
- "import pedpy\n",
"import pathlib\n",
+ "\n",
"import matplotlib.pyplot as plt\n",
+ "import pedpy\n",
"\n",
"experimental_trajectories = pedpy.load_trajectory(\n",
" trajectory_file=pathlib.Path(\"demo-data/bottleneck/040_c_56_h-.txt\")\n",
diff --git a/notebooks/journey.ipynb b/notebooks/journey.ipynb
index 491311cb2..d4cbfc96e 100644
--- a/notebooks/journey.ipynb
+++ b/notebooks/journey.ipynb
@@ -33,15 +33,14 @@
},
"outputs": [],
"source": [
- "from shapely import Polygon\n",
"import pathlib\n",
- "import pandas as pd\n",
- "import numpy as np\n",
+ "\n",
"import jupedsim as jps\n",
- "import pedpy\n",
- "from pedpy.column_identifier import ID_COL, FRAME_COL\n",
"import matplotlib.pyplot as plt\n",
+ "import numpy as np\n",
+ "import pedpy\n",
"from matplotlib.patches import Circle\n",
+ "from shapely import Polygon\n",
"\n",
"%matplotlib inline"
]
@@ -112,9 +111,7 @@
"plt.fill(x, y, alpha=0.1)\n",
"plt.plot(x, y, color=\"white\")\n",
"centroid = distribution_polygon.centroid\n",
- "plt.text(\n",
- " centroid.x, centroid.y, \"Start\", ha=\"center\", va=\"center\", fontsize=10\n",
- ")\n",
+ "plt.text(centroid.x, centroid.y, \"Start\", ha=\"center\", va=\"center\", fontsize=10)\n",
"\n",
"x, y = Polygon(exit_polygon).exterior.xy\n",
"plt.fill(x, y, alpha=0.1)\n",
@@ -132,7 +129,7 @@
")\n",
"ax.add_patch(circle)\n",
"ax.annotate(\n",
- " f\"Switch\",\n",
+ " \"Switch\",\n",
" (switch_point[0], switch_point[1]),\n",
" textcoords=\"offset points\",\n",
" xytext=(-5, -15),\n",
@@ -200,9 +197,7 @@
"metadata": {},
"outputs": [],
"source": [
- "def shortest_path(\n",
- " simulation: jps.Simulation, switch_id, waypoint_ids, exit_id\n",
- "):\n",
+ "def shortest_path(simulation: jps.Simulation, switch_id, waypoint_ids, exit_id):\n",
" \"\"\"Build a journey with fixed transitions for a given simulation.\"\"\"\n",
"\n",
" journey = jps.JourneyDescription([switch_id, *waypoint_ids, exit_id])\n",
@@ -467,9 +462,10 @@
"metadata": {},
"outputs": [],
"source": [
- "from scipy import stats\n",
"from typing import Tuple\n",
+ "\n",
"import numpy.typing as npt\n",
+ "from scipy import stats\n",
"\n",
"\n",
"def calculate_density_average_classic(\n",
@@ -512,7 +508,6 @@
"\n",
"\n",
"def plot_classical_density_profile(data, walkable_area, name, dx, rho_max):\n",
- " vmax = rho_max\n",
" geominX, geominY, geomaxX, geomaxY = walkable_area.bounds\n",
" title = f\"{name}\"\n",
" fig = make_subplots(rows=1, cols=1, subplot_titles=([title]))\n",
@@ -564,6 +559,7 @@
"outputs": [],
"source": [
"import math\n",
+ "\n",
"import plotly.graph_objects as go\n",
"\n",
"dx = 0.5\n",
diff --git a/notebooks/lane-formation.ipynb b/notebooks/lane-formation.ipynb
index 04830ecd8..0f8a7125c 100644
--- a/notebooks/lane-formation.ipynb
+++ b/notebooks/lane-formation.ipynb
@@ -11,12 +11,12 @@
"outputs": [],
"source": [
"import pathlib\n",
- "import pandas as pd\n",
- "import numpy as np\n",
+ "\n",
"import jupedsim as jps\n",
- "from shapely import Polygon\n",
- "import pedpy\n",
"import matplotlib.pyplot as plt\n",
+ "import numpy as np\n",
+ "import pedpy\n",
+ "from shapely import Polygon\n",
"\n",
"%matplotlib inline"
]
@@ -170,8 +170,7 @@
" simulation.add_exit_stage(exit_polygon_right),\n",
" ]\n",
" journeys = [\n",
- " simulation.add_journey(jps.JourneyDescription([exit]))\n",
- " for exit in exits\n",
+ " simulation.add_journey(jps.JourneyDescription([exit])) for exit in exits\n",
" ]\n",
"\n",
" # first group\n",
diff --git a/notebooks/motivation.ipynb b/notebooks/motivation.ipynb
index b4866bda1..960960d94 100644
--- a/notebooks/motivation.ipynb
+++ b/notebooks/motivation.ipynb
@@ -34,13 +34,12 @@
},
"outputs": [],
"source": [
- "from shapely import Polygon\n",
"import pathlib\n",
- "import pandas as pd\n",
- "import numpy as np\n",
+ "\n",
"import jupedsim as jps\n",
- "import pedpy\n",
"import matplotlib.pyplot as plt\n",
+ "import pedpy\n",
+ "from shapely import Polygon\n",
"\n",
"%matplotlib inline"
]
@@ -82,9 +81,7 @@
" plt.fill(x, y, alpha=0.1)\n",
" plt.plot(x, y, color=\"white\")\n",
" centroid = Polygon(area).centroid\n",
- " plt.text(\n",
- " centroid.x, centroid.y, name, ha=\"center\", va=\"center\", fontsize=8\n",
- " )"
+ " plt.text(centroid.x, centroid.y, name, ha=\"center\", va=\"center\", fontsize=8)"
]
},
{
diff --git a/notebooks/queues_waiting.ipynb b/notebooks/queues_waiting.ipynb
index 9f983b0ce..0d2b79695 100644
--- a/notebooks/queues_waiting.ipynb
+++ b/notebooks/queues_waiting.ipynb
@@ -33,15 +33,13 @@
},
"outputs": [],
"source": [
- "from shapely import from_wkt, Polygon, intersection\n",
- "import pedpy\n",
+ "import pathlib\n",
+ "\n",
"import jupedsim as jps\n",
- "import matplotlib.pyplot as plt\n",
+ "import pedpy\n",
"from matplotlib.patches import Circle\n",
- "import pathlib\n",
- "import pandas as pd\n",
- "import numpy as np\n",
- "from numpy.random import normal # normal distribution of free movement speed"
+ "from numpy.random import normal # normal distribution of free movement speed\n",
+ "from shapely import Polygon, from_wkt, intersection"
]
},
{
@@ -577,8 +575,7 @@
"gate_offsets = [0 for i in range(number_of_gates)]\n",
"\n",
"while (\n",
- " simulation.agent_count() > 0\n",
- " and simulation.iteration_count() < 5 * 60 * 100\n",
+ " simulation.agent_count() > 0 and simulation.iteration_count() < 5 * 60 * 100\n",
"):\n",
" for i in range(number_of_gates):\n",
" if queue_gates[i].count_enqueued() == 0:\n",
@@ -808,9 +805,7 @@
"source": [
"from jupedsim.internal.notebook_utils import animate, read_sqlite_file\n",
"\n",
- "trajectory_data_uneven, walkable_area = read_sqlite_file(\n",
- " trajectory_file_uneven\n",
- ")\n",
+ "trajectory_data_uneven, walkable_area = read_sqlite_file(trajectory_file_uneven)\n",
"animate(trajectory_data_uneven, walkable_area, every_nth_frame=5)"
]
},
diff --git a/notebooks/routing.ipynb b/notebooks/routing.ipynb
index 6aa27ccd2..c1d680ce2 100644
--- a/notebooks/routing.ipynb
+++ b/notebooks/routing.ipynb
@@ -32,14 +32,13 @@
"outputs": [],
"source": [
"import pathlib\n",
- "import pandas as pd\n",
- "import numpy as np\n",
+ "\n",
"import jupedsim as jps\n",
- "import shapely\n",
- "from shapely import Polygon\n",
- "import pedpy\n",
"import matplotlib.pyplot as plt\n",
+ "import pedpy\n",
+ "import shapely\n",
"from matplotlib.patches import Circle\n",
+ "from shapely import Polygon\n",
"\n",
"%matplotlib inline"
]
@@ -67,9 +66,7 @@
" (5.2, 0.0),\n",
" ]\n",
" ),\n",
- " Polygon(\n",
- " [(15, 19), (15, 5), (7.2, 5), (7.2, 4.8), (15.2, 4.8), (15.2, 19)]\n",
- " ),\n",
+ " Polygon([(15, 19), (15, 5), (7.2, 5), (7.2, 4.8), (15.2, 4.8), (15.2, 19)]),\n",
"]\n",
"\n",
"exit_polygon = [(19, 19), (20, 19), (20, 20), (19, 20)]\n",
@@ -115,9 +112,7 @@
"x, y = distribution_polygon.exterior.xy\n",
"plt.fill(x, y, alpha=0.1, color=\"blue\")\n",
"centroid = distribution_polygon.centroid\n",
- "plt.text(\n",
- " centroid.x, centroid.y, \"Start\", ha=\"center\", va=\"center\", fontsize=10\n",
- ")"
+ "plt.text(centroid.x, centroid.y, \"Start\", ha=\"center\", va=\"center\", fontsize=10)"
]
},
{
diff --git a/notebooks/single-file.ipynb b/notebooks/single-file.ipynb
index 29aceedee..826b25673 100644
--- a/notebooks/single-file.ipynb
+++ b/notebooks/single-file.ipynb
@@ -26,16 +26,16 @@
],
"source": [
"import pathlib\n",
- "import pandas as pd\n",
- "import numpy as np\n",
- "import jupedsim as jps\n",
- "from shapely import Polygon\n",
- "import shapely\n",
- "import pedpy\n",
- "import matplotlib.pyplot as plt\n",
"\n",
"# from matplotlib.patches import Circle\n",
- "from typing import List, Tuple, Dict\n",
+ "from typing import Dict, List, Tuple\n",
+ "\n",
+ "import jupedsim as jps\n",
+ "import matplotlib.pyplot as plt\n",
+ "import numpy as np\n",
+ "import pedpy\n",
+ "import shapely\n",
+ "from shapely import Polygon\n",
"\n",
"%matplotlib inline"
]
diff --git a/performancetest/comparison.ipynb b/performancetest/comparison.ipynb
index a3efe7a33..509202fe2 100644
--- a/performancetest/comparison.ipynb
+++ b/performancetest/comparison.ipynb
@@ -9,10 +9,10 @@
},
"outputs": [],
"source": [
+ "import glob\n",
"import sqlite3\n",
+ "\n",
"import pandas as pd\n",
- "import pathlib\n",
- "import glob\n",
"\n",
"\n",
"def import_from_sqlite(file):\n",
diff --git a/performancetest/generate-flamegraphs.py b/performancetest/generate-flamegraphs.py
index ec8d39fab..2f3713fb6 100755
--- a/performancetest/generate-flamegraphs.py
+++ b/performancetest/generate-flamegraphs.py
@@ -6,7 +6,6 @@
import logging
import os
import pathlib
-import shutil
import tarfile
import docker
diff --git a/performancetest/grosser_stern.py b/performancetest/grosser_stern.py
index 65a4f13dd..80ccdd5e6 100755
--- a/performancetest/grosser_stern.py
+++ b/performancetest/grosser_stern.py
@@ -9,9 +9,8 @@
import sys
import time
-import shapely
-
import jupedsim as jps
+
from performancetest.geometry import geometries
from performancetest.stats_writer import StatsWriter
diff --git a/performancetest/large_street_network.py b/performancetest/large_street_network.py
index f43c5907a..9c1f183e0 100755
--- a/performancetest/large_street_network.py
+++ b/performancetest/large_street_network.py
@@ -10,6 +10,7 @@
import time
import jupedsim as jps
+
from performancetest.geometry import geometries
from performancetest.stats_writer import StatsWriter
diff --git a/performancetest/single_run_analysis.ipynb b/performancetest/single_run_analysis.ipynb
index fb6e2748c..6374616f0 100644
--- a/performancetest/single_run_analysis.ipynb
+++ b/performancetest/single_run_analysis.ipynb
@@ -10,6 +10,7 @@
"outputs": [],
"source": [
"import sqlite3\n",
+ "\n",
"import pandas as pd\n",
"import shapely"
]
diff --git a/pyproject.toml b/pyproject.toml
index 56f68438f..fd0c18792 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,11 +1,56 @@
-[tool.black]
-line-length = 79
-target-version = ["py311", "py310"]
-extend-exclude = "^/(third-party|docs)"
-
-[tool.isort]
-profile = "black"
-py_version = "311"
-line_length = 79
-extend_skip = ["docs", "third-party"]
-known_first_party = ["jupedsim"]
+[tool.ruff]
+extend-exclude = ["third-party", "docs"]
+line-length = 80
+indent-width = 4
+target-version = "py312"
+extend-include = ["*.ipynb"]
+
+[tool.ruff.lint]
+# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
+# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
+# McCabe complexity (`C901`) by default.
+# select = ["E4", "E7", "E9", "F"]
+select = [
+ # pycodestyle
+ "E",
+ # Pyflakes
+ "F",
+ # isort
+ "I",
+]
+ignore = ["E501"]
+
+# Allow fix for all enabled rules (when `--fix`) is provided.
+fixable = ["ALL"]
+unfixable = []
+
+# Allow unused variables when underscore-prefixed.
+dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
+
+[tool.ruff.format]
+# Like Black, use double quotes for strings.
+quote-style = "double"
+
+# Like Black, indent with spaces, rather than tabs.
+indent-style = "space"
+
+# Like Black, respect magic trailing commas.
+skip-magic-trailing-comma = false
+
+# Like Black, automatically detect the appropriate line ending.
+line-ending = "auto"
+
+# Enable auto-formatting of code examples in docstrings. Markdown,
+# reStructuredText code/literal blocks and doctests are all supported.
+#
+# This is currently disabled by default, but it is planned for this
+# to be opt-out in the future.
+docstring-code-format = false
+
+# Set the line length limit used when formatting code snippets in
+# docstrings.
+#
+# This only has an effect when the `docstring-code-format` setting is
+# enabled.
+docstring-code-line-length = "dynamic"
+
diff --git a/python_modules/jupedsim/jupedsim/distributions.py b/python_modules/jupedsim/jupedsim/distributions.py
index c75a3c94c..f73b2600b 100644
--- a/python_modules/jupedsim/jupedsim/distributions.py
+++ b/python_modules/jupedsim/jupedsim/distributions.py
@@ -107,7 +107,7 @@ def distribute_by_number(
"""
if not isinstance(polygon, shapely.Polygon):
raise IncorrectParameterError(
- f"Polygon is expected to be a shapely Polygon"
+ "Polygon is expected to be a shapely Polygon"
)
box = __get_bounding_box(polygon)
@@ -183,7 +183,7 @@ def distribute_by_density(
if not isinstance(polygon, shapely.Polygon):
raise IncorrectParameterError(
- f"Polygon is expected to be a shapely Polygon"
+ "Polygon is expected to be a shapely Polygon"
)
area = polygon.area
number = round(density * area)
@@ -204,7 +204,7 @@ def __catch_wrong_inputs(
if not isinstance(polygon, shapely.Polygon):
raise IncorrectParameterError(
- f"Polygon is expected to be a shapely Polygon"
+ "Polygon is expected to be a shapely Polygon"
)
try:
if len(center_point) != 2:
@@ -338,9 +338,10 @@ def distribute_in_circles_by_number(
)
# determines a random degree
theta = np.random.uniform(0, 2 * np.pi)
- pt = center_point[0] + rho * np.cos(theta), center_point[
- 1
- ] + rho * np.sin(theta)
+ pt = (
+ center_point[0] + rho * np.cos(theta),
+ center_point[1] + rho * np.sin(theta),
+ )
if __check_distance_constraints(
pt, distance_to_polygon, grid, polygon
):
@@ -499,7 +500,7 @@ def distribute_until_filled(
"""
if not isinstance(polygon, shapely.Polygon):
raise IncorrectParameterError(
- f"Polygon is expected to be a shapely Polygon"
+ "Polygon is expected to be a shapely Polygon"
)
box = __get_bounding_box(polygon)
@@ -544,9 +545,10 @@ def distribute_until_filled(
)
# determines a random degree
theta = np.random.uniform(0, 2 * np.pi)
- pt = ref_point[0] + rho * np.cos(theta), ref_point[
- 1
- ] + rho * np.sin(theta)
+ pt = (
+ ref_point[0] + rho * np.cos(theta),
+ ref_point[1] + rho * np.sin(theta),
+ )
if __check_distance_constraints(
pt, distance_to_polygon, grid, polygon
):
diff --git a/python_modules/jupedsim/jupedsim/internal/aabb.py b/python_modules/jupedsim/jupedsim/internal/aabb.py
index a52da21ca..e51d0db75 100644
--- a/python_modules/jupedsim/jupedsim/internal/aabb.py
+++ b/python_modules/jupedsim/jupedsim/internal/aabb.py
@@ -6,7 +6,7 @@ def __init__(
) -> None:
if xmax < xmin or ymax < ymin:
raise Exception(
- f"Invalid arguments to create AABB: max values have to be larger than min values."
+ "Invalid arguments to create AABB: max values have to be larger than min values."
)
self.xmin = xmin
self.xmax = xmax
diff --git a/python_modules/jupedsim/jupedsim/internal/notebook_utils.py b/python_modules/jupedsim/jupedsim/internal/notebook_utils.py
index 89cfc71dd..00b2db41b 100644
--- a/python_modules/jupedsim/jupedsim/internal/notebook_utils.py
+++ b/python_modules/jupedsim/jupedsim/internal/notebook_utils.py
@@ -5,7 +5,7 @@
We make no promises about the functions from this file w.r.t. API stability. We
reservere us the right to change the code here w.o. warning. Do not use the
-code here. Use it at your own peril.
+code here. Use it at your own peril.
"""
import sqlite3
@@ -207,7 +207,8 @@ def _create_fig(
minx, miny, maxx, maxy = area_bounds
title = f"{title_note + ' | ' if title_note else ''}Number of Agents: {initial_agent_count}"
fig = go.Figure(
- data=geometry_traces + initial_scatter_trace
+ data=geometry_traces
+ + initial_scatter_trace
# + hover_traces
+ initial_hover_trace,
frames=frames,
diff --git a/python_modules/jupedsim/jupedsim/journey.py b/python_modules/jupedsim/jupedsim/journey.py
index b2d912d39..dba53c1be 100644
--- a/python_modules/jupedsim/jupedsim/journey.py
+++ b/python_modules/jupedsim/jupedsim/journey.py
@@ -47,7 +47,7 @@ def create_fixed_transition(stage_id: int) -> "Transition":
@staticmethod
def create_round_robin_transition(
- stage_weights: list[tuple[int, int]]
+ stage_weights: list[tuple[int, int]],
) -> "Transition":
"""Create a round-robin transition.
diff --git a/python_modules/jupedsim/jupedsim/native/__init__.py b/python_modules/jupedsim/jupedsim/native/__init__.py
index d84bb25c7..e40cd74ec 100644
--- a/python_modules/jupedsim/jupedsim/native/__init__.py
+++ b/python_modules/jupedsim/jupedsim/native/__init__.py
@@ -3,9 +3,9 @@
try:
import py_jupedsim as py_jps
- from py_jupedsim import *
+ from py_jupedsim import * # noqa: F403
except ImportError:
from .. import py_jupedsim as py_jps
- from ..py_jupedsim import *
+ from ..py_jupedsim import * # noqa: F403
__all__ = [name for name in dir(py_jps) if not name.startswith("__")]
diff --git a/python_modules/jupedsim/jupedsim/routing.py b/python_modules/jupedsim/jupedsim/routing.py
index 4f5766c2e..a28c6528f 100644
--- a/python_modules/jupedsim/jupedsim/routing.py
+++ b/python_modules/jupedsim/jupedsim/routing.py
@@ -24,9 +24,7 @@ def __init__(
),
**kwargs: Any,
) -> None:
- self._obj = py_jps.RoutingEngine(
- build_geometry(geometry, *kwargs)._obj
- )
+ self._obj = py_jps.RoutingEngine(build_geometry(geometry, *kwargs)._obj)
def compute_waypoints(
self, frm: tuple[float, float], to: tuple[float, float]
diff --git a/python_modules/jupedsim/jupedsim/serialization.py b/python_modules/jupedsim/jupedsim/serialization.py
index 458c82d6a..8576f2a6c 100644
--- a/python_modules/jupedsim/jupedsim/serialization.py
+++ b/python_modules/jupedsim/jupedsim/serialization.py
@@ -1,6 +1,6 @@
# Copyright © 2012-2024 Forschungszentrum Jülich GmbH
# SPDX-License-Identifier: LGPL-3.0-or-later
-""" Serialization/deserialization support
+"""Serialization/deserialization support
In this file you will find interfaces and implementations to serialize and
deserialize different forms of input / output commonly used.
diff --git a/python_modules/jupedsim/jupedsim/sqlite_serialization.py b/python_modules/jupedsim/jupedsim/sqlite_serialization.py
index 72ea8a97d..33f21ec0c 100644
--- a/python_modules/jupedsim/jupedsim/sqlite_serialization.py
+++ b/python_modules/jupedsim/jupedsim/sqlite_serialization.py
@@ -6,7 +6,7 @@
from pathlib import Path
from typing import Final
-from shapely import box, from_wkt
+from shapely import from_wkt
from jupedsim.serialization import TrajectoryWriter
from jupedsim.simulation import Simulation
diff --git a/python_modules/jupedsim/tests/test_build_geometry.py b/python_modules/jupedsim/tests/test_build_geometry.py
index 57d5b7a99..159b33c17 100644
--- a/python_modules/jupedsim/tests/test_build_geometry.py
+++ b/python_modules/jupedsim/tests/test_build_geometry.py
@@ -1,9 +1,7 @@
# Copyright © 2012-2024 Forschungszentrum Jülich GmbH
# SPDX-License-Identifier: LGPL-3.0-or-later
-import numpy as np
import pytest
import shapely
-
from jupedsim.util import GeometryError, _polygons_from_geometry_collection
@@ -94,12 +92,10 @@ def test_polygons_from_geometry_collection(geometry_input):
shapely.get_type_id(geometry_input)
== shapely.GeometryType.GEOMETRYCOLLECTION
) or (
- shapely.get_type_id(geometry_input)
- == shapely.GeometryType.MULTIPOLYGON
+ shapely.get_type_id(geometry_input) == shapely.GeometryType.MULTIPOLYGON
):
- reference = [geo for geo in geometry_input.geoms]
+ [geo for geo in geometry_input.geoms]
else:
- reference = [geometry_input]
geometry_input = shapely.GeometryCollection([geometry_input])
result = _polygons_from_geometry_collection(geometry_input)
diff --git a/python_modules/jupedsim/tests/test_distributions.py b/python_modules/jupedsim/tests/test_distributions.py
index 77eabc185..1f6a9c6a2 100644
--- a/python_modules/jupedsim/tests/test_distributions.py
+++ b/python_modules/jupedsim/tests/test_distributions.py
@@ -3,7 +3,6 @@
import math
import pytest
-
from jupedsim import distributions
diff --git a/python_modules/jupedsim/tests/test_recordings.py b/python_modules/jupedsim/tests/test_recordings.py
index c637f9e4f..4bdf4e5f9 100644
--- a/python_modules/jupedsim/tests/test_recordings.py
+++ b/python_modules/jupedsim/tests/test_recordings.py
@@ -2,8 +2,6 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import sqlite3
-import pytest
-
from jupedsim.recording import Recording
diff --git a/python_modules/jupedsim_visualizer/jupedsim_visualizer/__init__.py b/python_modules/jupedsim_visualizer/jupedsim_visualizer/__init__.py
index 3107d9e8b..8288ff612 100644
--- a/python_modules/jupedsim_visualizer/jupedsim_visualizer/__init__.py
+++ b/python_modules/jupedsim_visualizer/jupedsim_visualizer/__init__.py
@@ -6,4 +6,4 @@
import jupedsim_visualizer.grid
import jupedsim_visualizer.main_window
import jupedsim_visualizer.move_controller
-import jupedsim_visualizer.view_geometry_widget
+import jupedsim_visualizer.view_geometry_widget # noqa: F401
diff --git a/python_modules/jupedsim_visualizer/jupedsim_visualizer/geometry.py b/python_modules/jupedsim_visualizer/jupedsim_visualizer/geometry.py
index 936ae06fa..6ddbf05c7 100644
--- a/python_modules/jupedsim_visualizer/jupedsim_visualizer/geometry.py
+++ b/python_modules/jupedsim_visualizer/jupedsim_visualizer/geometry.py
@@ -1,11 +1,11 @@
# Copyright © 2012-2024 Forschungszentrum Jülich GmbH
# SPDX-License-Identifier: LGPL-3.0-or-later
-import math
import sys
-from jupedsim_visualizer.config import Colors, ZLayers
+from jupedsim import RoutingEngine
+from jupedsim.internal.aabb import AABB
from PySide6.QtCore import QObject, Signal
-from vtkmodules.vtkCommonCore import vtkCommand, vtkIntArray, vtkPoints
+from vtkmodules.vtkCommonCore import vtkCommand, vtkPoints
from vtkmodules.vtkCommonDataModel import vtkCellArray, vtkPolyData, vtkPolygon
from vtkmodules.vtkInteractionStyle import vtkInteractorStyleUser
from vtkmodules.vtkRenderingCore import (
@@ -15,8 +15,7 @@
vtkRenderer,
)
-from jupedsim import RoutingEngine
-from jupedsim.internal.aabb import AABB
+from jupedsim_visualizer.config import Colors, ZLayers
class Geometry:
diff --git a/python_modules/jupedsim_visualizer/jupedsim_visualizer/geometry_widget.py b/python_modules/jupedsim_visualizer/jupedsim_visualizer/geometry_widget.py
index 1fed34dfc..523e8ee27 100644
--- a/python_modules/jupedsim_visualizer/jupedsim_visualizer/geometry_widget.py
+++ b/python_modules/jupedsim_visualizer/jupedsim_visualizer/geometry_widget.py
@@ -1,19 +1,16 @@
# Copyright © 2012-2024 Forschungszentrum Jülich GmbH
# SPDX-License-Identifier: LGPL-3.0-or-later
-import vtkmodules.vtkRenderingOpenGL2
-from jupedsim_visualizer.config import Colors
-from jupedsim_visualizer.geometry import Geometry, HoverInfo
-from jupedsim_visualizer.grid import Grid
-from jupedsim_visualizer.move_controller import MoveController
+import jupedsim as jps
+from jupedsim.internal.aabb import AABB
from PySide6.QtCore import Signal
-from PySide6.QtGui import QPaintEvent
-from PySide6.QtWidgets import QWidget
from vtkmodules.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
from vtkmodules.vtkInteractionStyle import vtkInteractorStyleUser
from vtkmodules.vtkRenderingCore import vtkRenderer
-import jupedsim as jps
-from jupedsim.internal.aabb import AABB
+from jupedsim_visualizer.config import Colors
+from jupedsim_visualizer.geometry import HoverInfo
+from jupedsim_visualizer.grid import Grid
+from jupedsim_visualizer.move_controller import MoveController
class RenderWidget(QVTKRenderWindowInteractor):
diff --git a/python_modules/jupedsim_visualizer/jupedsim_visualizer/grid.py b/python_modules/jupedsim_visualizer/jupedsim_visualizer/grid.py
index 5f569d253..a91dc9d22 100644
--- a/python_modules/jupedsim_visualizer/jupedsim_visualizer/grid.py
+++ b/python_modules/jupedsim_visualizer/jupedsim_visualizer/grid.py
@@ -2,7 +2,6 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import math
-from jupedsim_visualizer.config import Colors, ZLayers
from vtkmodules.vtkCommonCore import vtkCommand
from vtkmodules.vtkFiltersSources import vtkPlaneSource
from vtkmodules.vtkRenderingCore import (
@@ -12,6 +11,8 @@
vtkRenderer,
)
+from jupedsim_visualizer.config import Colors, ZLayers
+
class Grid:
def __init__(self, renderer: vtkRenderer, cam: vtkCamera):
diff --git a/python_modules/jupedsim_visualizer/jupedsim_visualizer/main_window.py b/python_modules/jupedsim_visualizer/jupedsim_visualizer/main_window.py
index f13f9e227..388f19bab 100644
--- a/python_modules/jupedsim_visualizer/jupedsim_visualizer/main_window.py
+++ b/python_modules/jupedsim_visualizer/jupedsim_visualizer/main_window.py
@@ -3,11 +3,9 @@
import math
from pathlib import Path
+import jupedsim as jps
import shapely
-from jupedsim_visualizer.geometry import Geometry
-from jupedsim_visualizer.replay_widget import ReplayWidget
-from jupedsim_visualizer.trajectory import Trajectory
-from jupedsim_visualizer.view_geometry_widget import ViewGeometryWidget
+from jupedsim.recording import Recording
from PySide6.QtCore import QSettings, QSize
from PySide6.QtStateMachine import QFinalState, QState, QStateMachine
from PySide6.QtWidgets import (
@@ -18,8 +16,10 @@
QTabWidget,
)
-import jupedsim as jps
-from jupedsim.recording import Recording
+from jupedsim_visualizer.geometry import Geometry
+from jupedsim_visualizer.replay_widget import ReplayWidget
+from jupedsim_visualizer.trajectory import Trajectory
+from jupedsim_visualizer.view_geometry_widget import ViewGeometryWidget
class MainWindow(QMainWindow):
@@ -51,9 +51,7 @@ def _build_menu_bar(self) -> None:
open_replay_act = open_menu.addAction("Open replay file")
open_replay_act.triggered.connect(self._open_replay)
settings_menu = menu.addMenu("Settings")
- self._show_triangulation = settings_menu.addAction(
- "show triangulation"
- )
+ self._show_triangulation = settings_menu.addAction("show triangulation")
self._show_triangulation.setCheckable(True)
self._show_triangulation.toggled.connect(self._toggle_triangulation)
self._show_triangulation.setChecked(
diff --git a/python_modules/jupedsim_visualizer/jupedsim_visualizer/move_controller.py b/python_modules/jupedsim_visualizer/jupedsim_visualizer/move_controller.py
index 8508f76cd..893743d69 100644
--- a/python_modules/jupedsim_visualizer/jupedsim_visualizer/move_controller.py
+++ b/python_modules/jupedsim_visualizer/jupedsim_visualizer/move_controller.py
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import math
-from jupedsim_visualizer.config import ZLayers
+from jupedsim import RoutingEngine
from vtkmodules.vtkCommonCore import vtkCommand, vtkPoints
from vtkmodules.vtkCommonDataModel import (
vtkCellArray,
@@ -12,7 +12,7 @@
from vtkmodules.vtkInteractionStyle import vtkInteractorStyleUser
from vtkmodules.vtkRenderingCore import vtkActor, vtkCamera, vtkPolyDataMapper
-from jupedsim import RoutingEngine
+from jupedsim_visualizer.config import ZLayers
class MoveController:
@@ -29,9 +29,7 @@ def __init__(
self.dist = 0
interactor_style.AddObserver(vtkCommand.CharEvent, self._on_char)
- interactor_style.AddObserver(
- vtkCommand.KeyPressEvent, self._ignore_evt
- )
+ interactor_style.AddObserver(vtkCommand.KeyPressEvent, self._ignore_evt)
interactor_style.AddObserver(
vtkCommand.KeyReleaseEvent, self._ignore_evt
)
diff --git a/python_modules/jupedsim_visualizer/jupedsim_visualizer/replay_widget.py b/python_modules/jupedsim_visualizer/jupedsim_visualizer/replay_widget.py
index 663a85794..ad61767b2 100644
--- a/python_modules/jupedsim_visualizer/jupedsim_visualizer/replay_widget.py
+++ b/python_modules/jupedsim_visualizer/jupedsim_visualizer/replay_widget.py
@@ -2,9 +2,8 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import math
-from jupedsim_visualizer.geometry import Geometry
-from jupedsim_visualizer.geometry_widget import RenderWidget
-from jupedsim_visualizer.trajectory import Trajectory
+from jupedsim import RoutingEngine
+from jupedsim.recording import Recording
from PySide6.QtCore import QSignalBlocker, Qt, QTimer
from PySide6.QtGui import QFont, QPaintEvent
from PySide6.QtStateMachine import QState, QStateMachine
@@ -20,8 +19,9 @@
QWidget,
)
-from jupedsim import RoutingEngine
-from jupedsim.recording import Recording
+from jupedsim_visualizer.geometry import Geometry
+from jupedsim_visualizer.geometry_widget import RenderWidget
+from jupedsim_visualizer.trajectory import Trajectory
class PlayerControlWidget(QWidget):
diff --git a/python_modules/jupedsim_visualizer/jupedsim_visualizer/trajectory.py b/python_modules/jupedsim_visualizer/jupedsim_visualizer/trajectory.py
index 03ced9c7b..ad58d5546 100644
--- a/python_modules/jupedsim_visualizer/jupedsim_visualizer/trajectory.py
+++ b/python_modules/jupedsim_visualizer/jupedsim_visualizer/trajectory.py
@@ -1,14 +1,14 @@
# Copyright © 2012-2024 Forschungszentrum Jülich GmbH
# SPDX-License-Identifier: LGPL-3.0-or-later
-from jupedsim_visualizer.config import Colors, ZLayers
+from jupedsim.internal.aabb import AABB
+from jupedsim.recording import Recording, RecordingFrame
from vtkmodules.vtkCommonCore import vtkPoints
from vtkmodules.vtkCommonDataModel import vtkPolyData
from vtkmodules.vtkFiltersCore import vtkGlyph2D
from vtkmodules.vtkFiltersSources import vtkRegularPolygonSource
from vtkmodules.vtkRenderingCore import vtkActor, vtkPolyDataMapper
-from jupedsim.internal.aabb import AABB
-from jupedsim.recording import Recording, RecordingFrame
+from jupedsim_visualizer.config import Colors, ZLayers
def to_vtk_points(frame: RecordingFrame) -> vtkPoints:
diff --git a/python_modules/jupedsim_visualizer/jupedsim_visualizer/view_geometry_widget.py b/python_modules/jupedsim_visualizer/jupedsim_visualizer/view_geometry_widget.py
index f961c8d9e..835f97d6d 100644
--- a/python_modules/jupedsim_visualizer/jupedsim_visualizer/view_geometry_widget.py
+++ b/python_modules/jupedsim_visualizer/jupedsim_visualizer/view_geometry_widget.py
@@ -1,7 +1,6 @@
# Copyright © 2012-2024 Forschungszentrum Jülich GmbH
# SPDX-License-Identifier: LGPL-3.0-or-later
-from jupedsim_visualizer.geometry import Geometry
-from jupedsim_visualizer.geometry_widget import RenderWidget
+import jupedsim as jps
from PySide6.QtCore import Qt
from PySide6.QtGui import QPaintEvent
from PySide6.QtWidgets import (
@@ -12,7 +11,8 @@
QWidget,
)
-import jupedsim as jps
+from jupedsim_visualizer.geometry import Geometry
+from jupedsim_visualizer.geometry_widget import RenderWidget
class ViewGeometryWidget(QWidget):
diff --git a/requirements.txt b/requirements.txt
index 2ebc72786..00b8650f6 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -14,6 +14,4 @@ pandas~=2.1
# ci deps
jinja2
-black==24.4.0
-jupyter-black==0.3.4
-isort==5.13.2
+ruff
diff --git a/scripts/Merge_Trajectories.py b/scripts/Merge_Trajectories.py
index bc9f27b09..ed5c8c6d6 100644
--- a/scripts/Merge_Trajectories.py
+++ b/scripts/Merge_Trajectories.py
@@ -177,7 +177,7 @@ def test_exception_multiple_startvalues(self):
end_frames = [4777, 8857, 12470, 15761, 18817, 21684, 24393, 26178]
start_frames = [0, 0, 8858, 12471, 15762, 18818, 21685, 24394]
check_data((start_frames, end_frames))
- assert ex.exception.message == f"multiple files start with the frame 0"
+ assert ex.exception.message == "multiple files start with the frame 0"
def test_exception_frames_miss_between_files(self):
with self.assertRaises(IncorrectTrajectory) as ex:
@@ -186,7 +186,7 @@ def test_exception_frames_miss_between_files(self):
check_data((start_frames, end_frames))
assert (
ex.exception.message
- == f"the starting frame 4500 is not matching the other files"
+ == "the starting frame 4500 is not matching the other files"
)
def test_exception_frames_overlap(self):
@@ -196,7 +196,7 @@ def test_exception_frames_overlap(self):
check_data((start_frames, end_frames))
assert (
ex.exception.message
- == f"the starting frame 9000 is not matching the other files"
+ == "the starting frame 9000 is not matching the other files"
)
def test_read_header(self):
@@ -243,7 +243,10 @@ def test_read_data(self):
class TestFrameFromLine(unittest.TestCase):
def test_for_correct_frame(self):
self.assertEqual(
- frame_from_line("1 0 14.90 6.60 0.00 0.20 0.20 -165.96 0\n"), 0
+ frame_from_line(
+ "1 0 14.90 6.60 0.00 0.20 0.20 -165.96 0\n"
+ ),
+ 0,
)
def test_for_incorrect_format(self):
diff --git a/scripts/ci/check_format.sh b/scripts/ci/check_format.sh
index 2626f0de9..3c1dd637c 100755
--- a/scripts/ci/check_format.sh
+++ b/scripts/ci/check_format.sh
@@ -7,5 +7,5 @@ cmake --build . --target check-format -- VERBOSE=1
cd ..
-isort --check .
-black --check .
+ruff check --show-source
+ruff format --diff
diff --git a/scripts/copyrighter.py b/scripts/copyrighter.py
index b75d4515e..82ff46add 100755
--- a/scripts/copyrighter.py
+++ b/scripts/copyrighter.py
@@ -28,7 +28,7 @@ def update_year_to(file: Path, year: int, pattern: re.Pattern):
content = file.read_text().splitlines()
found = False
for line, idx in zip(content, range(5)):
- found = pattern.search(line) != None
+ found = pattern.search(line) is not None
if found:
content[idx] = pattern.sub(
f"Copyright © 2012-{year} Forschungszentrum Jülich GmbH", line
diff --git a/scripts/parse_dxf.py b/scripts/parse_dxf.py
index 50bd68f25..652ead25a 100644
--- a/scripts/parse_dxf.py
+++ b/scripts/parse_dxf.py
@@ -94,7 +94,7 @@ def polyline_to_polygon(polyline):
"a polyline has at most 2 points and can not be a Polygon"
)
raise IncorrectDXFFileError(
- f"a polyline could not be converted to a Polygon", [points]
+ "a polyline could not be converted to a Polygon", [points]
)
return Polygon(points)
@@ -193,7 +193,7 @@ def parse_dxf_file(
# create new Polygon with holes
simple_holes = polygonize(simple_holes)
- logging.debug(f"the geometry was parsed")
+ logging.debug("the geometry was parsed")
return outer_polygon.difference(simple_holes)
diff --git a/setup.py b/setup.py
index 7fb539bfc..88f3e6e07 100644
--- a/setup.py
+++ b/setup.py
@@ -51,7 +51,7 @@ def check_cmake():
):
if found_version < min_version:
return False
- except:
+ except Exception as _:
return False
return True
@@ -90,7 +90,7 @@ def check_cpp_compiler():
["cmake", "-S", str(tmp_dir), "-B", str(tmp_dir_build)],
check=True,
)
- except:
+ except Exception as _:
return False
return True
diff --git a/systemtest/test_model_constraints.py b/systemtest/test_model_constraints.py
index 7b296c65a..d59cf242f 100644
--- a/systemtest/test_model_constraints.py
+++ b/systemtest/test_model_constraints.py
@@ -1,12 +1,10 @@
# Copyright © 2012-2024 Forschungszentrum Jülich GmbH
# SPDX-License-Identifier: LGPL-3.0-or-later
-import logging
+import jupedsim as jps
import numpy as np
import pytest
-import jupedsim as jps
-
@pytest.fixture
def square_room_100x100():
@@ -44,9 +42,7 @@ def square_room_100x100_gcfm():
"radius",
np.arange(0.01, 2, 0.5),
)
-def test_collision_free_speed_model_can_set_radius(
- square_room_100x100, radius
-):
+def test_collision_free_speed_model_can_set_radius(square_room_100x100, radius):
simulation, journey_id, exit_id, agent_position = square_room_100x100
simulation.add_agent(
@@ -557,7 +553,6 @@ def test_generalized_centrifugal_force_model_can_not_set_b_max_too_small(
square_room_100x100_gcfm,
):
simulation, journey_id, exit_id, agent_position = square_room_100x100_gcfm
- b_min = 0.4
with pytest.raises(
RuntimeError, match=r"Model constraint violation: BMax 0.39 .*"
):
diff --git a/systemtest/test_model_properties.py b/systemtest/test_model_properties.py
index f0f7261e4..0725ff5b4 100644
--- a/systemtest/test_model_properties.py
+++ b/systemtest/test_model_properties.py
@@ -2,9 +2,8 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import math
-import pytest
-
import jupedsim as jps
+import pytest
@pytest.fixture
diff --git a/systemtest/test_py_jupedsim.py b/systemtest/test_py_jupedsim.py
index b04ebbbe6..061844df7 100644
--- a/systemtest/test_py_jupedsim.py
+++ b/systemtest/test_py_jupedsim.py
@@ -1,10 +1,9 @@
# Copyright © 2012-2024 Forschungszentrum Jülich GmbH
# SPDX-License-Identifier: LGPL-3.0-or-later
+import jupedsim as jps
import pytest
import shapely
-import jupedsim as jps
-
def test_can_query_agents_in_range():
messages = []
@@ -20,9 +19,7 @@ def log_msg_handler(msg):
model=jps.CollisionFreeSpeedModel(),
geometry=[(0, 0), (100, 0), (100, 100), (0, 100)],
)
- exit = simulation.add_exit_stage(
- [(99, 45), (99, 55), (100, 55), (100, 45)]
- )
+ exit = simulation.add_exit_stage([(99, 45), (99, 55), (100, 55), (100, 45)])
journey = jps.JourneyDescription([exit])
@@ -163,9 +160,7 @@ def log_msg_handler(msg):
]
)
waiting_set = simulation.get_stage(waiting_set_id)
- exit = simulation.add_exit_stage(
- [(99, 40), (99, 60), (100, 60), (100, 40)]
- )
+ exit = simulation.add_exit_stage([(99, 40), (99, 60), (100, 60), (100, 40)])
journey = jps.JourneyDescription([wp, waiting_set_id, exit])
journey.set_transition_for_stage(
wp, jps.Transition.create_fixed_transition(waiting_set_id)
diff --git a/systemtest/test_stages.py b/systemtest/test_stages.py
index eb7253d05..8432b3c88 100644
--- a/systemtest/test_stages.py
+++ b/systemtest/test_stages.py
@@ -1,10 +1,9 @@
# Copyright © 2012-2024 Forschungszentrum Jülich GmbH
# SPDX-License-Identifier: LGPL-3.0-or-later
+import jupedsim as jps
import pytest
import shapely
-import jupedsim as jps
-
@pytest.fixture
def square_room_5x5():
@@ -29,9 +28,7 @@ def square_room_5x5_with_obstacle():
def test_exception_on_empty_polygon_in_exit_stage(square_room_5x5):
sim = square_room_5x5
- with pytest.raises(
- Exception, match=rf"Polygon must have at least 3 points"
- ):
+ with pytest.raises(Exception, match=r"Polygon must have at least 3 points"):
sim.add_exit_stage([])
@@ -215,16 +212,14 @@ def test_can_not_add_waypoint_outside_geometry(square_room_5x5):
with pytest.raises(
RuntimeError, match="WayPoint .* not inside walkable area"
- ) as error_info:
+ ):
simulation.add_waypoint_stage((10, 10), 1)
def test_can_not_add_exit_completely_outside_geometry(square_room_5x5):
simulation = square_room_5x5
- with pytest.raises(
- RuntimeError, match=r"Exit .* not inside walkable area"
- ) as error_info:
+ with pytest.raises(RuntimeError, match=r"Exit .* not inside walkable area"):
simulation.add_exit_stage([(-10, -10), (-8, -10), (-8, -8), (-10, -8)])
@@ -238,9 +233,7 @@ def test_can_not_add_exit_partly_outside_geometry_centroid_outside(
):
simulation = square_room_5x5
- with pytest.raises(
- RuntimeError, match=r"Exit .* not inside walkable area"
- ) as error_info:
+ with pytest.raises(RuntimeError, match=r"Exit .* not inside walkable area"):
simulation.add_exit_stage([(-4, -4), (-4, -2), (-2, -2), (-2, -4)])
@@ -250,7 +243,7 @@ def test_can_not_add_notifiable_waiting_set_outside_geometry(square_room_5x5):
with pytest.raises(
RuntimeError,
match=r"NotifiableWaitingSet point .* not inside walkable area",
- ) as error_info:
+ ):
simulation.add_waiting_set_stage([(2, -2), (-10, -10)])
@@ -260,5 +253,5 @@ def test_can_not_add_notifiable_queue_outside_geometry(square_room_5x5):
with pytest.raises(
RuntimeError,
match=r"NotifiableQueue point .* not inside walkable area",
- ) as error_info:
+ ):
simulation.add_queue_stage([(2, -2), (-10, -10)])