Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
toruseo committed Nov 25, 2024
2 parents 0efbe5c + d6b9a97 commit 56d7697
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/measure-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Run verifications with pytest
run: pytest -n auto 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 tests/test_verification_multilane.py tests/test_verification_taxi.py tests/test_other_functions.py --durations=0 -v --cov=uxsim --cov-report=xml --cov-config=.github/.coveragerc
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.6.0
uses: codecov/codecov-action@v5.0.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
Expand Down
1 change: 1 addition & 0 deletions tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"example_14en_multiple_signals_Deep_Reinforcement_Learning_pytorch.py", #takes too much time. DQN can be tested by example_12en_* as well.
"example_17en_result_GUI_viewer_sioux_falls.py", #GUI viewer is not testable in Github Actions
"example_18en_result_GUI_viewer_grid.py", #GUI viewer is not testable in Github Actions
"example_16en_import_from_OpenStreetMap.py", #inconsist with OSMnx 2.0.0. TODO: fix
]

# Dynamically generate test cases for each example script
Expand Down
51 changes: 26 additions & 25 deletions tests/test_other_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,34 +77,35 @@ def test_analyzer():

assert True

@pytest.mark.filterwarnings("ignore::UserWarning")
def test_osm_import():
from uxsim.OSMImporter import OSMImporter

W = World(
name="",
deltan=5,
tmax=7200,
print_mode=1, save_mode=1, show_mode=0,
random_seed=0
)

#Tokyo highway
nodes, links = OSMImporter.import_osm_data(bbox=(35.817, 35.570, 139.881, 139.583), custom_filter='["highway"~"motorway"]')
nodes, links = OSMImporter.osm_network_postprocessing(nodes, links, node_merge_threshold=0.005, node_merge_iteration=5, enforce_bidirectional=True) # merge threshold distance: 0.005 degree ~= 500 m. `enforce_bidirectional` makes all links bidirectional, so that network is not fragmented (but the original network topology is not preserved rigorously).
OSMImporter.osm_network_visualize(nodes, links, show_link_name=0, show_mode=0, save_mode=0)
OSMImporter.osm_network_to_World(W, nodes, links, default_jam_density=0.2, coef_degree_to_meter=111000)
W.show_network()
#inconsist with OSMnx 2.0.0. TODO: fix
# @pytest.mark.filterwarnings("ignore::UserWarning")
# def test_osm_import():
# from uxsim.OSMImporter import OSMImporter

# W = World(
# name="",
# deltan=5,
# tmax=7200,
# print_mode=1, save_mode=1, show_mode=0,
# random_seed=0
# )

# #Tokyo highway
# nodes, links = OSMImporter.import_osm_data(bbox=(35.817, 35.570, 139.881, 139.583), custom_filter='["highway"~"motorway"]')
# nodes, links = OSMImporter.osm_network_postprocessing(nodes, links, node_merge_threshold=0.005, node_merge_iteration=5, enforce_bidirectional=True) # merge threshold distance: 0.005 degree ~= 500 m. `enforce_bidirectional` makes all links bidirectional, so that network is not fragmented (but the original network topology is not preserved rigorously).
# OSMImporter.osm_network_visualize(nodes, links, show_link_name=0, show_mode=0, save_mode=0)
# OSMImporter.osm_network_to_World(W, nodes, links, default_jam_density=0.2, coef_degree_to_meter=111000)
# W.show_network()

# set demand to central Tokyo from surroundings
W.adddemand_area2area(139.70, 35.60, 0, 139.75, 35.68, 0.05, 0, 3600, volume=5000)
W.adddemand_area2area(139.65, 35.70, 0, 139.75, 35.68, 0.05, 0, 3600, volume=5000)
W.adddemand_area2area(139.75, 35.75, 0, 139.75, 35.68, 0.05, 0, 3600, volume=5000)
W.adddemand_area2area(139.85, 35.70, 0, 139.75, 35.68, 0.05, 0, 3600, volume=5000)
# # set demand to central Tokyo from surroundings
# W.adddemand_area2area(139.70, 35.60, 0, 139.75, 35.68, 0.05, 0, 3600, volume=5000)
# W.adddemand_area2area(139.65, 35.70, 0, 139.75, 35.68, 0.05, 0, 3600, volume=5000)
# W.adddemand_area2area(139.75, 35.75, 0, 139.75, 35.68, 0.05, 0, 3600, volume=5000)
# W.adddemand_area2area(139.85, 35.70, 0, 139.75, 35.68, 0.05, 0, 3600, volume=5000)

W.exec_simulation()
# W.exec_simulation()

assert equal_tolerance(len(W.VEHICLES), 5000*4/5)
# assert equal_tolerance(len(W.VEHICLES), 5000*4/5)

def test_readme():
import re, requests
Expand Down

0 comments on commit 56d7697

Please sign in to comment.