metrics-mvp icon indicating copy to clipboard operation
metrics-mvp copied to clipboard

Add unit tests to arrival time algorithms

Open Eochs opened this issue 6 years ago • 3 comments

Add tests to "data science" functions to allow newcomers to get better grasp of what functions are doing, shape of data input/output, and to allow easier changing/fixing of functions.

Functions to test are in: backend/models/eclipses.py backend/models/wait_times.py backend/models/trip_times.py

Any questions about the functions or data should be directed to @youngj (Jesse Young on Slack).

Eochs avatar Nov 07 '19 04:11 Eochs

For example, there should be a unit test for find_arrivals in eclipses.py to verify the algorithm works correctly when a vehicle goes two directions on a street during one run of a route. There needs to be test data like for the SF Muni 39-Coit line which runs east, then west on Union Street when inbound to Fisherman's Wharf. The problem is that currently a westbound bus might be associated with an eastbound stop when calculating an arrival time. This error is visible in the UI where the Travel time along route plot is discontinuous with some decreasing sections. Whereas for other "normal" routes without any backtracking along the route, the plot is non-decreasing. It would be great if we could replicate this type of backtracking scenario in a unit test of find_arrivals to verify that it handles these conditions correctly.

jimtyhurst avatar Nov 07 '19 08:11 jimtyhurst

Another interesting test case is the SF Muni 29 Sunset inbound. The Gilman and 3rd St stop is so close to the starting stop that no complete trips on the route are recorded. Notice the absence of speed data going into Gilman and 3rd St.

Screen Shot 2019-11-26 at 4 58 01 PM

exxonvaldez avatar Nov 27 '19 01:11 exxonvaldez

Some routes that would be good to have unit tests for:

  • TriMet route 50 (figure 8 loop)
  • Muni 36-Teresita (optional Myra Way branch that is sometimes bypassed)
  • Muni 39-Coit (contains backtracking and twisty segments)
  • Portland Streetcar B Loop (11th and Marshall terminal close to 10th and Northrup stop)

youngj avatar Feb 22 '20 22:02 youngj