Skip to content

Commit

Permalink
test update
Browse files Browse the repository at this point in the history
  • Loading branch information
toruseo committed Mar 25, 2024
1 parent a36fb15 commit 71d606f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-gui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
run: pip install .
- name: Install pytest other dependencies
run: pip install pytest setuptools
- name: Run verifications with pytest
- name: Run test with pytest
run: pytest tests/test_result_gui_viewer.py --durations=0 -v
5 changes: 1 addition & 4 deletions .github/workflows/verify-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ on:
jobs:
verify-module:
runs-on: ubuntu-latest
strategy:
matrix:
test-script: [tests/test_verification_straight_road.py tests/test_verification_route_choice.py tests/test_verification_node.py tests/test_verification_exceptional.py tests/test_verification_sioux_falls.py]
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
Expand All @@ -24,4 +21,4 @@ jobs:
- name: Install pytest other dependencies
run: pip install pytest pytest-rerunfailures setuptools
- name: Run verifications with pytest
run: pytest ${{ matrix.test-script }} --durations=0 -v
run: pytest tests/test_verification_sioux_falls.py tests/test_verification_straight_road.py tests/test_verification_route_choice.py tests/test_verification_node.py tests/test_verification_exceptional.py --durations=0 -v -n auto
79 changes: 41 additions & 38 deletions tests/test_result_gui_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,44 @@
"""

import pytest
import uxsim as UX
from uxsim.ResultGUIViewer import ResultGUIViewer

#simple network
W = UX.World(
name="", # Scenario name
deltan=5, # Simulation aggregation unit delta n
tmax=1200, # Total simulation time (s)
print_mode=1, save_mode=1, show_mode=1, # Various options
random_seed=0 # Set the random seed
)

# Define the scenario
W.addNode("orig1", 0, 0) # Create a node
W.addNode("orig2", 0, 2)
W.addNode("merge", 0.5, 1)
W.addNode("dest", 1, 1)
W.addLink("link1", "orig1", "merge", length=1000, free_flow_speed=20, jam_density=0.2, merge_priority=0.5) # Create a link
W.addLink("link2", "orig2", "merge", length=1000, free_flow_speed=20, jam_density=0.2, merge_priority=2)
W.addLink("link3", "merge", "dest", length=1000, free_flow_speed=20, jam_density=0.2)
W.adddemand("orig1", "dest", 0, 1000, 0.4) # Create OD traffic demand
W.adddemand("orig2", "dest", 500, 1000, 0.6)


# Run the simulation to the end
W.exec_simulation()

# Print summary of simulation result
W.analyzer.print_simple_stats()

app, window = ResultGUIViewer.launch_World_viewer(W, return_app_window=True)

from PyQt5.QtCore import QTimer
import sys
timer = QTimer()
timer.timeout.connect(window.close)
timer.start(1000*5)
sys.exit(app.exec_())

def test_result_gui_viewer():
import uxsim as UX
from uxsim.ResultGUIViewer import ResultGUIViewer

#simple network
W = UX.World(
name="", # Scenario name
deltan=5, # Simulation aggregation unit delta n
tmax=1200, # Total simulation time (s)
print_mode=1, save_mode=1, show_mode=1, # Various options
random_seed=0 # Set the random seed
)

# Define the scenario
W.addNode("orig1", 0, 0) # Create a node
W.addNode("orig2", 0, 2)
W.addNode("merge", 0.5, 1)
W.addNode("dest", 1, 1)
W.addLink("link1", "orig1", "merge", length=1000, free_flow_speed=20, jam_density=0.2, merge_priority=0.5) # Create a link
W.addLink("link2", "orig2", "merge", length=1000, free_flow_speed=20, jam_density=0.2, merge_priority=2)
W.addLink("link3", "merge", "dest", length=1000, free_flow_speed=20, jam_density=0.2)
W.adddemand("orig1", "dest", 0, 1000, 0.4) # Create OD traffic demand
W.adddemand("orig2", "dest", 500, 1000, 0.6)


# Run the simulation to the end
W.exec_simulation()

# Print summary of simulation result
W.analyzer.print_simple_stats()

app, window = ResultGUIViewer.launch_World_viewer(W, return_app_window=True)

# Shut down 5 sec later
from PyQt5.QtCore import QTimer
import sys
timer = QTimer()
timer.timeout.connect(window.close)
timer.start(1000*5)
sys.exit(app.exec_())

0 comments on commit 71d606f

Please sign in to comment.