Skip to content

Commit

Permalink
Merge pull request #1326 from cal-itp/readability-pass
Browse files Browse the repository at this point in the history
Clean up functions in segment_speed_utils
  • Loading branch information
tiffanychu90 authored Dec 18, 2024
2 parents 61e0bd9 + bc64698 commit 15e0120
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 366 deletions.
5 changes: 2 additions & 3 deletions rt_segment_speeds/scripts/interpolate_stop_arrival.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
from pathlib import Path
from typing import Literal, Optional

from segment_speed_utils import (array_utils, helpers,
segment_calcs)
from segment_speed_utils import helpers, segment_calcs
from update_vars import SEGMENT_GCS, GTFS_DATA_DICT
from segment_speed_utils.project_vars import PROJECT_CRS, SEGMENT_TYPES
from shared_utils import rt_dates
Expand Down Expand Up @@ -166,7 +165,7 @@ def enforce_monotonicity_and_interpolate_across_stops(
df = segment_calcs.convert_timestamp_to_seconds(
df, ["arrival_time"])

df = array_utils.rolling_window_make_array(
df = segment_calcs.rolling_window_make_array(
df,
window = 3, rolling_col = "arrival_time_sec"
)
Expand Down
3 changes: 2 additions & 1 deletion rt_segment_speeds/scripts/nearest_vp_to_stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""
import datetime
import geopandas as gpd
import numpy as np
import pandas as pd
import sys

Expand Down Expand Up @@ -158,7 +159,7 @@ def nearest_neighbor_for_stop(
gdf = neighbor.merge_stop_vp_for_nearest_neighbor(stop_times, analysis_date)

vp_before, vp_after, vp_before_meters, vp_after_meters = np.vectorize(
neighbor.subset_arrays_to_valid_directions
neighbor.two_nearest_neighbor_near_stop
)(
gdf.vp_primary_direction,
gdf.vp_geometry,
Expand Down
5 changes: 3 additions & 2 deletions rt_segment_speeds/scripts/pipeline_rt_stop_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

logger.remove()


LOG_FILE = "../logs/interpolate_stop_arrival.log"
logger.add(LOG_FILE, retention="3 months")
logger.add(sys.stderr,
Expand All @@ -57,7 +57,7 @@

logger.remove()


LOG_FILE = "../logs/speeds_by_segment_trip.log"
logger.add(LOG_FILE, retention="3 months")
logger.add(sys.stderr,
Expand All @@ -75,3 +75,4 @@
[compute(i)[0] for i in delayed_dfs]

logger.remove()

7 changes: 4 additions & 3 deletions rt_segment_speeds/scripts/pipeline_segment_speeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
if __name__ == "__main__":

from segment_speed_utils.project_vars import analysis_date_list

segment_type = "stop_segments"
print(f"segment_type: {segment_type}")

Expand Down Expand Up @@ -59,7 +59,7 @@

logger.remove()


LOG_FILE = "../logs/speeds_by_segment_trip.log"
logger.add(LOG_FILE, retention="3 months")
logger.add(sys.stderr,
Expand All @@ -76,4 +76,5 @@

[compute(i)[0] for i in delayed_dfs]

logger.remove()
logger.remove()

7 changes: 4 additions & 3 deletions rt_segment_speeds/scripts/pipeline_speedmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def concatenate_speedmap_proxy_arrivals_with_remaining(

logger.remove()


LOG_FILE = "../logs/interpolate_stop_arrival.log"
logger.add(LOG_FILE, retention="3 months")
logger.add(sys.stderr,
Expand All @@ -109,7 +109,7 @@ def concatenate_speedmap_proxy_arrivals_with_remaining(

logger.remove()


t0 = datetime.datetime.now()
delayed_dfs = [
delayed(concatenate_speedmap_proxy_arrivals_with_remaining)(
Expand Down Expand Up @@ -139,4 +139,5 @@ def concatenate_speedmap_proxy_arrivals_with_remaining(

[compute(i)[0] for i in delayed_dfs]

logger.remove()
logger.remove()

269 changes: 0 additions & 269 deletions rt_segment_speeds/scripts/vp_around_stops.py

This file was deleted.

2 changes: 0 additions & 2 deletions rt_segment_speeds/segment_speed_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from . import (
array_utils,
gtfs_schedule_wrangling,
helpers,
metrics,
Expand All @@ -12,7 +11,6 @@
)

__all__ = [
"array_utils",
"gtfs_schedule_wrangling",
"helpers",
"metrics",
Expand Down
Loading

0 comments on commit 15e0120

Please sign in to comment.