Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
AshishKuls committed Apr 22, 2024
1 parent 5e777d6 commit 7d00678
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 99 deletions.
15 changes: 1 addition & 14 deletions tm2py/acceptance/acceptance.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


class Acceptance:

s: Simulated
o: Observed
c: Canonical
Expand Down Expand Up @@ -77,7 +76,7 @@ class Acceptance:
"technology": pd.Series(dtype="str"),
"route_short_name": pd.Series(dtype="str"),
"route_long_name": pd.Series(dtype="str"),
#"trip_headsign": pd.Series(dtype="str"),
# "trip_headsign": pd.Series(dtype="str"),
"time_period": pd.Series(dtype="str"),
"route_observed_boardings": pd.Series(dtype="float"),
"route_simulated_boardings": pd.Series(dtype="float"),
Expand Down Expand Up @@ -133,31 +132,27 @@ def make_acceptance(self, make_transit=True, make_roadway=True, make_other=False
return

def _write_roadway_network(self):

file_root = self.acceptance_output_folder_root
out_file = os.path.join(file_root, self.output_roadway_filename)
self.road_network_gdf.to_file(out_file, driver="GeoJSON")

return

def _write_transit_network(self):

file_root = self.acceptance_output_folder_root
out_file = os.path.join(file_root, self.output_transit_filename)
self.transit_network_gdf.to_file(out_file, driver="GeoJSON")

return

def _write_other_comparisons(self):

file_root = self.acceptance_output_folder_root
out_file = os.path.join(file_root, self.output_other_filename)
self.compare_gdf.to_file(out_file, driver="GeoJSON")

return

def _make_roadway_network_comparisons(self):

o_df = self.o.reduced_traffic_counts_df.copy()
o_trans_df = self.o.observed_bridge_transactions_df.copy()
s_df = self.s.simulated_roadway_assignment_results_df.copy()
Expand Down Expand Up @@ -391,7 +386,6 @@ def compare_transit_boardings(self) -> pd.DataFrame:
return boards_df

def _make_transit_network_comparisons(self):

# step 1: outer merge for rail operators (ignore route)
# step 2: left merge for non-rail operators
boards_df = self.compare_transit_boardings()
Expand Down Expand Up @@ -498,7 +492,6 @@ def _make_transit_network_comparisons(self):
return

def _make_other_comparisons(self):

a_df = self._make_home_work_flow_comparisons()
b_gdf = self._make_zero_vehicle_household_comparisons()
c_gdf = self._make_bart_station_to_station_comparisons()
Expand All @@ -516,7 +509,6 @@ def _make_other_comparisons(self):
def _fix_technology_labels(
self, input_df: pd.DataFrame, column_name: str
) -> pd.DataFrame:

assert column_name in input_df.columns

r_df = input_df.copy()
Expand All @@ -543,7 +535,6 @@ def _fix_technology_labels(
return r_df

def _make_home_work_flow_comparisons(self):

adjust_observed = (
self.s.simulated_home_work_flows_df.simulated_flow.sum()
/ self.o.ctpp_2012_2016_df.observed_flow.sum()
Expand Down Expand Up @@ -577,7 +568,6 @@ def _make_home_work_flow_comparisons(self):
return df

def _make_zero_vehicle_household_comparisons(self):

c_df = self.s.reduced_simulated_zero_vehicle_hhs_df

# prepare the observed data
Expand Down Expand Up @@ -617,7 +607,6 @@ def _make_zero_vehicle_household_comparisons(self):
return gdf

def _make_bart_station_to_station_comparisons(self):

s_df = self.s.simulated_station_to_station_df.copy()

df = pd.merge(
Expand Down Expand Up @@ -651,7 +640,6 @@ def _make_bart_station_to_station_comparisons(self):
return r_gdf

def _make_rail_access_comparisons(self):

PARK_AND_RIDE_OBSERVED_THRESHOLD = 500

s_df = self.s.simulated_transit_access_df.copy()
Expand Down Expand Up @@ -754,7 +742,6 @@ def _make_rail_access_comparisons(self):
return r_gdf

def _make_transit_district_flow_comparisons(self):

s_df = self.s.simulated_transit_district_to_district_by_tech_df.copy()
o_df = self.o.reduced_transit_district_flows_by_technology_df.copy()

Expand Down
11 changes: 0 additions & 11 deletions tm2py/acceptance/canonical.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Canonical:

canonical_dict: dict
canonical_file: str

Expand Down Expand Up @@ -63,7 +62,6 @@ class Canonical:
]

def _load_configs(self):

with open(self.canonical_file, "r", encoding="utf-8") as toml_file:
self.canonical_dict = toml.load(toml_file)

Expand All @@ -89,7 +87,6 @@ def __init__(
return

def _make_canonical_agency_names_dict(self):

file_root = self.canonical_dict["remote_io"]["crosswalk_folder_root"]
in_file = self.canonical_dict["crosswalks"]["canonical_agency_names_file"]

Expand Down Expand Up @@ -137,7 +134,6 @@ def _make_canonical_agency_names_dict(self):
return

def _make_canonical_station_names_dict(self):

file_root = self.canonical_dict["remote_io"]["crosswalk_folder_root"]
in_file = self.canonical_dict["crosswalks"]["canonical_station_names_file"]

Expand All @@ -149,7 +145,6 @@ def _make_canonical_station_names_dict(self):

running_operator_dict = {}
for operator in df["operator"].unique():

o_df = df[df["operator"] == operator].copy()

a_df = o_df[["canonical"]].copy()
Expand All @@ -176,14 +171,12 @@ def _make_canonical_station_names_dict(self):
return

def _make_census_maz_crosswalk(self):

url_string = self.canonical_dict["crosswalks"]["block_group_to_maz_url"]
self.census_2010_to_maz_crosswalk_df = pd.read_csv(url_string)

return

def _read_standard_to_emme_transit(self):

root_dir = self.canonical_dict["remote_io"]["crosswalk_folder_root"]
in_file = self.canonical_dict["crosswalks"]["standard_to_emme_transit_file"]

Expand All @@ -194,7 +187,6 @@ def _read_standard_to_emme_transit(self):
return

def _make_tm2_to_gtfs_mode_crosswalk(self):

file_root = self.canonical_dict["remote_io"]["crosswalk_folder_root"]
in_file = self.canonical_dict["crosswalks"]["standard_to_tm2_modes_file"]

Expand All @@ -215,7 +207,6 @@ def _make_tm2_to_gtfs_mode_crosswalk(self):
return

def _read_standard_transit_to_survey_crosswalk(self):

file_root = self.canonical_dict["remote_io"]["crosswalk_folder_root"]
in_file = self.canonical_dict["crosswalks"]["crosswalk_standard_survey_file"]

Expand Down Expand Up @@ -243,15 +234,13 @@ def _read_standard_transit_to_survey_crosswalk(self):
def aggregate_line_names_across_time_of_day(
self, input_df: pd.DataFrame, input_column_name: str
) -> pd.DataFrame:

df = input_df[input_column_name].str.split(pat="_", expand=True).copy()
df["daily_line_name"] = df[0] + "_" + df[1] + "_" + df[2]
return_df = pd.concat([input_df, df["daily_line_name"]], axis="columns")

return return_df

def _read_taz_to_district_crosswalk(self):

file_root = self.canonical_dict["remote_io"]["crosswalk_folder_root"]
in_file = self.canonical_dict["crosswalks"]["taz_to_district_file"]

Expand Down
18 changes: 0 additions & 18 deletions tm2py/acceptance/observed.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class Observed:

c: Canonical

observed_dict: dict
Expand Down Expand Up @@ -143,7 +142,6 @@ class Observed:
reduced_transit_district_flows_by_technology_df: pd.DataFrame

def _load_configs(self):

with open(self.observed_file, "r", encoding="utf-8") as toml_file:
self.observed_dict = toml.load(toml_file)

Expand All @@ -165,7 +163,6 @@ def __init__(
self._reduce_observed_rail_access_summaries()

def _validate(self):

if self.reduced_transit_on_board_df.empty:
self.reduce_on_board_survey()

Expand Down Expand Up @@ -193,7 +190,6 @@ def _validate(self):
return

def _join_florida_thresholds(self, input_df: pd.DataFrame) -> pd.DataFrame:

df = self.florida_transit_guidelines_df.copy()
df["high"] = df["boardings"].shift(-1)
df["low"] = df["boardings"]
Expand Down Expand Up @@ -231,7 +227,6 @@ def _join_florida_thresholds(self, input_df: pd.DataFrame) -> pd.DataFrame:
return pd.concat([return_df, other_df], axis="rows", ignore_index=True)

def _join_standard_route_id(self, input_df: pd.DataFrame) -> pd.DataFrame:

df = self.c.standard_transit_to_survey_df.copy()

df["survey_agency"] = df["survey_agency"].map(
Expand Down Expand Up @@ -352,7 +347,6 @@ def reduce_on_board_survey(self, read_file_from_disk=True):
return

def _reduce_census_zero_car_households(self):

file_root = self.observed_dict["remote_io"]["obs_folder_root"]
in_file = self.observed_dict["census"]["vehicles_by_block_group_file"]

Expand All @@ -378,7 +372,6 @@ def _reduce_census_zero_car_households(self):
return

def _reduce_observed_bart_boardings(self):

file_root = self.observed_dict["remote_io"]["obs_folder_root"]
in_file = self.observed_dict["transit"]["bart_boardings_file"]

Expand Down Expand Up @@ -407,7 +400,6 @@ def _reduce_observed_bart_boardings(self):
return

def _make_census_geo_crosswalk(self):

file_root = self.observed_dict["remote_io"]["obs_folder_root"]
pickle_file = self.observed_dict["census"]["census_geographies_pickle"]
tract_geojson_file = self.observed_dict["census"][
Expand Down Expand Up @@ -453,7 +445,6 @@ def _make_census_geo_crosswalk(self):
def _make_tract_centroids(
self, input_gdf: gpd.GeoDataFrame, out_file: str
) -> gpd.GeoDataFrame:

t_gdf = input_gdf.dissolve(by="TRACTCE10")
c_gdf = t_gdf.to_crs(3857).centroid.to_crs(4326).reset_index()
df = pd.DataFrame(t_gdf.reset_index())[["TRACTCE10", "COUNTYFP10", "STATEFP10"]]
Expand All @@ -471,7 +462,6 @@ def _make_tract_centroids(
return

def _reduce_ctpp_2012_2016(self):

file_root = self.observed_dict["remote_io"]["obs_folder_root"]
in_file = self.observed_dict["census"]["ctpp_2012_2016_file"]

Expand All @@ -497,7 +487,6 @@ def _reduce_ctpp_2012_2016(self):
return

def _reduce_observed_rail_access_summaries(self):

root_dir = self.observed_dict["remote_io"]["obs_folder_root"]
in_file = self.observed_dict["transit"]["reduced_access_summary_file"]

Expand All @@ -517,7 +506,6 @@ def _reduce_observed_rail_access_summaries(self):
return

def _reduce_observed_rail_flow_summaries(self):

root_dir = self.observed_dict["remote_io"]["obs_folder_root"]
in_file = self.observed_dict["transit"]["reduced_flow_summary_file"]

Expand All @@ -528,7 +516,6 @@ def _reduce_observed_rail_flow_summaries(self):
return

def _make_district_to_district_transit_flows_by_technology(self):

o_df = self.reduced_transit_spatial_flow_df.copy()
o_df = o_df[o_df["time_period"] == "am"].copy()

Expand Down Expand Up @@ -565,7 +552,6 @@ def _make_district_to_district_transit_flows_by_technology(self):
return

def _join_tm2_node_ids(self, input_df: pd.DataFrame) -> pd.DataFrame:

df = input_df.copy()
nodes_df = self.c.standard_to_emme_node_crosswalk_df.copy()

Expand All @@ -592,7 +578,6 @@ def _join_tm2_node_ids(self, input_df: pd.DataFrame) -> pd.DataFrame:
return df

def _join_ohio_standards(self, input_df: pd.DataFrame) -> pd.DataFrame:

df = self.ohio_rmse_standards_df.copy()

df["upper"] = (
Expand Down Expand Up @@ -651,7 +636,6 @@ def _join_ohio_standards(self, input_df: pd.DataFrame) -> pd.DataFrame:
def _identify_key_arterials_and_bridges(
self, input_df: pd.DataFrame
) -> pd.DataFrame:

df1 = self.key_arterials_df.copy()
df2 = self.bridges_df.copy()
df = pd.concat([df1, df2])[["name", "direction", "pems_station_id"]].rename(
Expand All @@ -667,7 +651,6 @@ def _identify_key_arterials_and_bridges(
return out_df

def _reduce_truck_counts(self) -> pd.DataFrame:

file_root = self.observed_dict["remote_io"]["obs_folder_root"]
in_file = self.observed_dict["roadway"]["pems_truck_count_file"]

Expand Down Expand Up @@ -896,7 +879,6 @@ def _reduce_pems_counts(self, read_file_from_disk=True):
return return_df

def _reduce_caltrans_counts(self):

file_root = self.observed_dict["remote_io"]["obs_folder_root"]
in_file = self.observed_dict["roadway"]["caltrans_count_file"]

Expand Down
Loading

0 comments on commit 7d00678

Please sign in to comment.