Skip to content

Commit 7df6aaf

Browse files
committed
add dependency deprecated
1 parent de04efe commit 7df6aaf

File tree

3 files changed

+44
-14
lines changed

3 files changed

+44
-14
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ docstring-code-line-length = "dynamic"
5454

5555
# Ignore naming issues for camelCase deprecated properties
5656
[tool.ruff.lint.pep8-naming]
57-
extend-ignore-names = ["desiredSpeed", "reactionTime", "agentScale", "obstacleScale", "forceDistance", "bodyForce"]
57+
extend-ignore-names = ["desiredSpeed", "reactionTime", "agentScale", "obstacleScale", "forceDistance", "bodyForce", "IncorrectTrajectory". "IncorrectTrajectoryError"]
5858

5959
[tool.ruff.lint.per-file-ignores]
6060
"test_perftests.py" = ["N"]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ numpy~=2.2
22
shapely~=2.0
33
pyside6~=6.8
44
vtk~=9.4
5-
5+
deprecated~=1.2.18
66
# build deps
77
wheel
88
build

systemtest/test_desired_speed.py

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,64 @@
11
# Copyright © 2012-2024 Forschungszentrum Jülich GmbH
22
# SPDX-License-Identifier: LGPL-3.0-or-later
3+
34
import jupedsim as jps
45
import pytest
56

67

78
@pytest.fixture
8-
def simulation_with_social_force_model():
9-
return jps.Simulation(
10-
model=jps.SocialForceModel(),
11-
geometry=[(0, 0), (10, 0), (10, 10), (0, 10)],
12-
)
9+
def create_simulation():
10+
"""Creates a generic simulation fixture for different models."""
11+
12+
def _create(model):
13+
return jps.Simulation(
14+
model=model,
15+
geometry=[(0, 0), (10, 0), (10, 10), (0, 10)],
16+
)
1317

18+
return _create
1419

15-
def test_desired_speed_deprecated(simulation_with_social_force_model):
16-
sim = simulation_with_social_force_model
20+
21+
@pytest.mark.parametrize(
22+
"model_class, agent_class, deprecated_attr",
23+
[
24+
(
25+
jps.SocialForceModel,
26+
jps.SocialForceModelAgentParameters,
27+
"desiredSpeed",
28+
),
29+
(
30+
jps.CollisionFreeSpeedModel,
31+
jps.CollisionFreeSpeedModelAgentParameters,
32+
"v0",
33+
),
34+
(
35+
jps.GeneralizedCentrifugalForceModel,
36+
jps.GeneralizedCentrifugalForceModelAgentParameters,
37+
"v0",
38+
),
39+
],
40+
)
41+
def test_desired_speed_deprecated(
42+
create_simulation, model_class, agent_class, deprecated_attr
43+
):
44+
"""
45+
Test that deprecated 'desiredSpeed' (or 'v0' in some models) raises warnings and is mapped to 'desired_speed'.
46+
"""
47+
sim = create_simulation(model_class())
1748
wp = sim.add_waypoint_stage((10, 1), 0.5)
1849
journey_id = sim.add_journey(jps.JourneyDescription([wp]))
1950

20-
agent = jps.SocialForceModelAgentParameters(
51+
agent = agent_class(
2152
journey_id=journey_id,
2253
stage_id=wp,
2354
position=(1, 1),
2455
)
2556
agent_id = sim.add_agent(agent)
26-
# Check if the deprecation warning is raised
57+
2758
with pytest.warns(
2859
DeprecationWarning, match="deprecated, use 'desired_speed' instead"
2960
):
30-
sim.agent(agent_id).model.desiredSpeed = 1.5
31-
assert sim.agent(agent_id).model.desiredSpeed == 1.5
61+
setattr(sim.agent(agent_id).model, deprecated_attr, 1.5)
62+
assert getattr(sim.agent(agent_id).model, deprecated_attr) == 1.5
3263

33-
# Verify the new snake_case property reflects the same value
3464
assert sim.agent(agent_id).model.desired_speed == 1.5

0 commit comments

Comments
 (0)