From ef4fd6c9a52c4ae09f4648144e7f1c9ee611db6e Mon Sep 17 00:00:00 2001 From: Kuan Butts Date: Fri, 27 Jul 2018 17:03:43 -0700 Subject: [PATCH] Refactor average cost reformatting for wait times (#96) * more explicit column resorting * break apart _format_summarized_outputs * explicit series conversion to dataframe * fix return * custom exception * another custom error * udpate error, uses placeholder * new test --- peartree/summarizer.py | 43 +++++++++++++++--- .../highdesertpointorus-2018-03-20.zip | Bin 0 -> 20657 bytes tests/test_paths.py | 11 +++++ 3 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 tests/fixtures/highdesertpointorus-2018-03-20.zip diff --git a/peartree/summarizer.py b/peartree/summarizer.py index e94c2a5..b5887ab 100644 --- a/peartree/summarizer.py +++ b/peartree/summarizer.py @@ -11,6 +11,22 @@ from peartree.utilities import log + +class InvalidParsedWaitTimes(Exception): + pass + +def _format_summarized_outputs(summarized: pd.Series) -> pd.DataFrame: + # The output of the group by produces a Series, but we want to extract + # the values from the index and the Series itself and generate a + # pandas DataFrame instead + original_stop_ids_index = summarized.index.values + original_series_values = summarized.values + + return pd.DataFrame({ + 'stop_id': original_stop_ids_index, + 'avg_cost': original_series_values}) + + def calculate_average_wait(direction_times: pd.DataFrame) -> float: # Exit early if we do not have enough values to calculate a mean at = direction_times.arrival_time @@ -131,14 +147,27 @@ def generate_summary_wait_times( dir_0_check_2 = df_sub[np.isnan(df_sub.wait_dir_0)] dir_1_check_2 = df_sub[np.isnan(df_sub.wait_dir_1)] - if (len(dir_0_check_2) > 0) or (len(dir_1_check_2) > 0): - raise Exception('NaN values for both directions on some stop IDs.') - - grouped = df_sub.groupby('stop_id') - summarized = grouped.apply(summarize_waits_at_one_stop) + dir_0_trigger = len(dir_0_check_2) > 0 + dir_1_trigger = len(dir_1_check_2) > 0 + if dir_0_trigger or dir_1_trigger: + raise InvalidParsedWaitTimes( + 'NaN values for both directions on some stop IDs.') + + # At this point, we should make sure that there are still values + # in the DataFrame - otherwise we are in a situation where there are + # no valid times to evaluate. This is okay; we just need to skip straight + # to the application of the fallback value + if df_sub.empty: + # So just make a fallback empty dataframe for now + summed_reset = pd.DataFrame({'stop_id': [], 'avg_cost': []}) + + # Only attempt this group by summary if at least one row to group on + else: + grouped = df_sub.groupby('stop_id') + summarized = grouped.apply(summarize_waits_at_one_stop) - summed_reset = summarized.reset_index(drop=False) - summed_reset.columns = ['stop_id', 'avg_cost'] + # Clean up summary results, reformat pandas DataFrame result + summed_reset = _format_summarized_outputs(summarized) end_of_stop_ids = summed_reset.stop_id.unique() log('Original stop id count: {}'.format(len(init_of_stop_ids))) diff --git a/tests/fixtures/highdesertpointorus-2018-03-20.zip b/tests/fixtures/highdesertpointorus-2018-03-20.zip new file mode 100644 index 0000000000000000000000000000000000000000..bb2416933c828cf11c05ac1f16750ed9cf7c6ace GIT binary patch literal 20657 zcmagG1yEdFvo<=w0E1?54}%4F3GVLh65L&aySuvtf@^?a0fGc~cXxNU{K@E5{`qZaZfa-j!QkTV5;9hc z+6}=B*=$$Xgb_q&%siUw5yJS2dKNrE8{ZiMKz+Kg!jH~czGtMAuoAolyOBE0@wG@( zDrtPZQ6!S<&lfLK{F)1|FmrKjC%Fs#4;sJUiW|cpTXg@5hWcmL z#L~&s*u~P`?mrZV80n?{5|kRGla^!nV-?0x_Y)z5hzN`^5e!ksOF?3E;mcGTW_WnM zJd+}sYR||(H>MhjCQuCJAK>JTepwCZz|-Gx!U~4wpyGF>MsZ~>^&b+6goPjq)ahMea&C=;Pu!XM-)f$eVkvLG9R%^x;DRD zpz@&{UfFgV{_adEh+oDo;;Q$^?7kOodu50*GeAkX6N@AB)UKC>^rV-d^0&l|C-vPo zLrtLt2**u3Mu9sPLF=qipeEZQQ?*fr#$jo@0XxZuVJh?4H(%h4enZsRX{r+a`789_ zpotEg`27_Mqkj$B-#Yut#?#*Jzo$XP(74Rskd;ACdPKC8>Gt(~;1(*QZh7>e7HrIr zcd*n~GSjj`i#M*`PQs1PfLAuo-_B0R)X7xoHnsXxx}A)uYGY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@@ -97,6 +97,17 @@ def test_loading_in_invalid_timeframes(): load_feed_as_graph(feed_1, start, end) +def test_parsing_when_just_on_trip_during_target_window(): + path = fixture('highdesertpointorus-2018-03-20.zip') + feed = get_representative_feed(path) + + start = 7*60*60 # 7:00 AM + end = 8*60*60 # 10:00 AM + G = load_feed_as_graph(feed, start, end) + assert len(list(G.nodes())) == 2 + assert len(list(G.edges())) == 1 + + def test_synthetic_network(): # Load in the GeoJSON as a JSON and convert to a dictionary geojson_path = fixture('synthetic_east_bay.geojson')