Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When running event handlers on counts with

subpopulation) in our simulations, we found NaN rows appeared in the outputlink_vehicle_counts_car_sub_subpopulationCSVs/GeoJSONs.It was confirmed that the NaN subpopulation rows originate from taxi trips — taxi vehicle IDs follow the pattern
{person_id}_taxi, so the code's direct vehicle-ID lookup against the person attributes dictionary always misses.Some actions in the CI build pipeline were out of date, which failed in GitHub Actions.
This PR aims to fix the bugs to make sure those NaN subpopulations will be added and removed them from the vehicle links counts outputs and any other relavent event handlers.
Root Cause Analysis
Elara builds an attributes dictionary keyed by person ID from
output_plans.xml.gz:Why taxi end up as NaN?
In MATSim, taxi declared as
networkMode="car", then the lookup happens in process_event() — event_handlers.py:The MATSim event XML does carry the person ID :
But Elara ignores
person=and usesvehicle=for the lookup. For regular car trips, vehicle == personso it works fine. For taxi and car_passenger tripsvehicle ≠ person`, so the lookup silently fails.Key Changes
Event Handlers (
elara/event_handlers.py)veh_to_personcache added toLinkVehicleCounts,LinkVehicleCapacity, andLinkVehicleSpeeds— populates onvehicle enters trafficevents, mapsvehicle_id → person_id, and is used on subsequententered link/left linkevents so that taxi vehicles (e.g.10628_taxi) correctly resolve to their person (10628) for attribute lookupextract_attribute_values()always includesNone—Noneis now always present as a fallback class regardless of attribute availability, with updated docstringfinalise()in six handlers:LinkVehicleCounts,LinkVehicleCapacity,LinkVehicleSpeeds,LinkPassengerCounts,StopPassengerCounts,StopToStopPassengerCounts, andRoutePassengerCounts— drops structural zero-count NaN rows after aggregation while preserving NaN rows that carry real counts (e.g. bus drivers whose person ID is not in attributes)Tests (
tests/test_2_event_handlers.py)finalisetest assertions to removenp.nanfrom expectedsubpopulationvalue sets — reflects corrected output where zero-count NaN rows are no longer present for car, passenger, route, stop, and stop-to-stop handlersVehiclePassengerGraphpickle fixtures to match new handler outputCI Fixes (
build_pipeline.yml)actions/checkoutv2 → v4,actions/setup-pythonv1 → v5,actions/cachev1 → v4, Python 3.7 → 3.8aws-uploadreusable workflowAWS Credentials Update
The CI was failing due to expired/invalid AWS credentials. The fix required:
bitbucket-s3AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYOnce the secrets were rotated, the CI pipeline passed successfully.