From 705e0713575183cc3da445f724d7ac43289e566c Mon Sep 17 00:00:00 2001 From: r-leyshon Date: Mon, 22 Jan 2024 11:27:46 +0000 Subject: [PATCH] feat: allow for use of viz_stops in MGTFS without stop_code column;feat: add new tests (#236) Co-authored-by: r-leyshon 7cc6c6292d3f6c77c5c3b2d5f715dec73f600c9c --- .../transport_performance/gtfs/multi_validation.html | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/_modules/transport_performance/gtfs/multi_validation.html b/_modules/transport_performance/gtfs/multi_validation.html index 25bd6733..9699f8fe 100644 --- a/_modules/transport_performance/gtfs/multi_validation.html +++ b/_modules/transport_performance/gtfs/multi_validation.html @@ -94,6 +94,7 @@

Source code for transport_performance.gtfs.multi_validation

import glob import os import warnings +from copy import deepcopy from geopandas import GeoDataFrame import numpy as np @@ -675,6 +676,13 @@

Source code for transport_performance.gtfs.multi_validation

# combine stop tables parts = [] for inst in self.instances: + # copy the gtfs instance in case data is manipulated + inst = deepcopy(inst) + # create a synthesized stop_code column if it does not exist + if "stop_code" not in inst.feed.stops.columns: + inst.feed.stops["stop_code"] = [ + f"ID{sid}" for sid in inst.feed.stops["stop_id"] + ] subset = inst.feed.stops[ ["stop_lat", "stop_lon", "stop_name", "stop_id", "stop_code"] ].copy() @@ -683,6 +691,8 @@

Source code for transport_performance.gtfs.multi_validation

subset = subset[subset.stop_id.isin(valid_ids)] subset["gtfs_path"] = os.path.basename(inst.gtfs_path) parts.append(subset) + # clean up copied instance + del inst all_stops = pd.concat(parts)