Skip to content

Commit

Permalink
return error if not enough data
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate-Wessel committed May 22, 2024
1 parent 1cad573 commit 51202c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion backend/app/get_travel_time.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from app.db import getConnection
from app.get_links import get_links
import math, numpy, random
import math, numpy, random, numbers

# the way we currently do it
def mean_daily_mean(obs):
Expand Down Expand Up @@ -75,6 +75,9 @@ def get_travel_time(start_node, end_node, start_time, end_time, start_date, end_
connection.close()
tt_hourly = [ tt for (dt,tt) in sample ]

if len(sample) < 1:
return {'error': 'not enough data'}

# bootstrap for synthetic sample distribution
sample_distribution = []
for i in range(0,100):
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/travelTimeQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export class TravelTimeQuery {
record.set('sample', this.#results.confidence.sample)
record.set('mean_travel_time_minutes', this.#results.travel_time.minutes)
record.set('mean_travel_time_seconds', this.#results.travel_time.seconds)
record.set('moe_lower_p95', this.#results.confidence.intervals['p=0.95'].lower.seconds)
record.set('moe_upper_p95', this.#results.confidence.intervals['p=0.95'].upper.seconds)

if(type=='json'){
return Object.fromEntries(record) // can't JSONify maps
Expand Down

0 comments on commit 51202c7

Please sign in to comment.