Skip to content

Commit

Permalink
Fix the overridden hack
Browse files Browse the repository at this point in the history
This fixes
https://github.com/e-mission/e-mission-server/issues/530#issuecomment-352197949

Also add a new test case that checks for this.
Also fix a small bug in the extraction script
  • Loading branch information
shankari committed Dec 16, 2017
1 parent ce9a6e7 commit 7fa0f5a
Show file tree
Hide file tree
Showing 5 changed files with 156,423 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bin/debug/extract_timeline_for_day_and_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

def export_timeline(user_id_str, day_str, file_name):
logging.info("Extracting timeline for user %s day %s and saving to file %s" %
(user_id_str, day_str, file))
(user_id_str, day_str, file_name))

# day_dt = pydt.datetime.strptime(day_str, "%Y-%m-%d").date()
day_dt = pydt.datetime.strptime(day_str, "%Y-%m-%d")
Expand Down
8 changes: 4 additions & 4 deletions emission/analysis/intake/cleaning/clean_and_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,14 +492,14 @@ def get_overriden_mode(raw_section_data, filtered_section_data, with_speeds_df):
# https://github.com/e-mission/e-mission-server/issues/407#issuecomment-248524098
if raw_section_data.sensed_mode == ecwm.MotionTypes.ON_FOOT:
if end_to_end_distance > 10 * 1000 and overall_speed > TEN_KMPH:
logging.info("Sanity checking failed for ON_FOOT section from trip (raw: %s, cleaned %s), returning UNKNOWN" %
(raw_section_data.trip_id, cleaned_section_data.trip_id))
logging.info("Sanity checking failed for ON_FOOT section from trip (raw: %s, filtered %s), returning UNKNOWN" %
(raw_section_data.trip_id, filtered_section_data.trip_id))
return ecwm.MotionTypes.UNKNOWN

if raw_section_data.sensed_mode == ecwm.MotionTypes.BICYCLING:
if end_to_end_distance > 100 * 1000 and overall_speed > TWENTY_KMPH:
logging.info("Sanity checking failed for BICYCLING section from trip (raw: %s, cleaned %s), returning UNKNOWN" %
(raw_section_data.trip_id, cleaned_section_data.trip_id))
logging.info("Sanity checking failed for BICYCLING section from trip (raw: %s, filtered %s), returning UNKNOWN" %
(raw_section_data.trip_id, filtered_section_data.trip_id))
return ecwm.MotionTypes.UNKNOWN

return None
Expand Down
14 changes: 14 additions & 0 deletions emission/tests/analysisTests/intakeTests/TestPipelineRealData.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,20 @@ def testTsMismatch(self):
self.compare_result(ad.AttrDict({'result': api_result}).result,
ad.AttrDict(ground_truth).data)

def testOverriddenModeHack(self):
# Test for https://github.com/e-mission/e-mission-server/issues/457
dataFile = "emission/tests/data/real_examples/test_overriden_mode_hack.jul-31"
start_ld = ecwl.LocalDate({'year': 2017, 'month': 7, 'day': 31})
cacheKey = "diary/trips-2017-07-31"
ground_truth = json.load(open("emission/tests/data/real_examples/test_overriden_mode_hack.jul-31.ground_truth"), object_hook=bju.object_hook)

etc.setupRealExample(self, dataFile)
etc.runIntakePipeline(self.testUUID)

api_result = gfc.get_geojson_for_dt(self.testUUID, start_ld, start_ld)
self.compare_result(ad.AttrDict({'result': api_result}).result,
ad.AttrDict(ground_truth).data)

if __name__ == '__main__':
etc.configLogging()
unittest.main()
Loading

0 comments on commit 7fa0f5a

Please sign in to comment.