Skip to content

Commit

Permalink
Fix assignment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samakinen committed Feb 6, 2025
1 parent 9ccada3 commit 1110e99
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Scripts/assignment/assignment_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def assign(self, matrices: dict, iteration: Union[int,str]) -> Dict:
Type (time/cost/dist) : dict
Assignment class (car_work/transit/...) : numpy 2-d matrix
"""
self.event_handler.on_assignment_started(self, iteration, matrices, self.emme_scenario)
self.event_handler.on_assignment_started(self, iteration, matrices)
self._set_emmebank_matrices(matrices, iteration=="last")
if iteration=="init":
self._assign_pedestrians()
Expand Down
6 changes: 3 additions & 3 deletions Scripts/events/model_system_event_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ def on_background_traffic_calculated(self, assignment_period: 'AssignmentPeriod'
pass

def on_assignment_started(self,
assignment_period: 'AssignmentPeriod',
iteration: Union[int, str],
demand: Dict[str, np.ndarray]) -> None:
assignment_period: 'AssignmentPeriod',
iteration: Union[int, str],
demand: Dict[str, np.ndarray]) -> None:
"""
Event handler for when Emme assignment is started.
Args:
Expand Down
3 changes: 2 additions & 1 deletion Scripts/tests/emme_only/test_assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import os
import logging
from events.model_system_event_listener import EventHandler
import utils.log as log
import numpy

Expand Down Expand Up @@ -70,7 +71,7 @@ def __init__(self):
emme_context.import_scenario(
os.path.join(project_dir, "..", "Network"), scenario_num, "test",
overwrite=True)
self.ass_model = ass.EmmeAssignmentModel(emme_context, scenario_num)
self.ass_model = ass.EmmeAssignmentModel(emme_context, scenario_num, EventHandler())
self.ass_model.prepare_network()

def test_assignment(self):
Expand Down
3 changes: 2 additions & 1 deletion Scripts/tests/unit/test_assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pandas
import os

from events.model_system_event_listener import EventHandler
from utils.validate_network import validate
from assignment.emme_bindings.mock_project import MockProject
from assignment.emme_assignment import EmmeAssignmentModel
Expand Down Expand Up @@ -32,7 +33,7 @@ def test_assignment(self):
context.modeller.emmebank.scenario(scenario_id).get_network(),
fares)
ass_model = EmmeAssignmentModel(
context, scenario_id)
context, scenario_id, EventHandler())
ass_model.prepare_network()
peripheral_cost = numpy.arange(10).reshape((1, 10))
ass_model.calc_transit_cost(fares, peripheral_cost)
Expand Down

0 comments on commit 1110e99

Please sign in to comment.