@@ -495,9 +495,10 @@ def split_log(x):
495
495
.rename ("operation_history" )
496
496
.reset_index ()
497
497
)
498
- action_history_df ["operation_final" ] = action_history_df .apply (lambda x : Project ._final_op (x ), axis = 1 )
499
-
498
+
500
499
link_df = pd .merge (link_df , action_history_df , on = ['A' , 'B' ], how = "left" )
500
+ link_df .drop_duplicates (subset = ['A' , 'B' ], keep = "last" , inplace = True )
501
+ link_df ["operation_final" ] = link_df .apply (lambda x : Project ._final_op (x ), axis = 1 )
501
502
502
503
if len (node_df ) > 0 :
503
504
action_history_df = (
@@ -506,9 +507,10 @@ def split_log(x):
506
507
.rename ("operation_history" )
507
508
.reset_index ()
508
509
)
509
- action_history_df ["operation_final" ] = action_history_df .apply (lambda x : Project ._final_op (x ), axis = 1 )
510
-
511
- node_df = pd .merge (node_df , action_history_df , on = 'N' , how = "left" )
510
+
511
+ node_df = pd .merge (node_df , action_history_df , on = ['N' ], how = "left" )
512
+ node_df .drop_duplicates (subset = ['N' ], keep = "last" , inplace = True )
513
+ node_df ["operation_final" ] = node_df .apply (lambda x : Project ._final_op (x ), axis = 1 )
512
514
513
515
WranglerLogger .info (
514
516
"Processed {} Node lines and {} Link lines" .format (
@@ -1080,8 +1082,39 @@ def _process_link_additions(
1080
1082
1081
1083
for x in add_col :
1082
1084
cube_add_df [x ] = cube_add_df [x ].astype (self .base_roadway_network .links_df [x ].dtype )
1085
+
1086
+ add_col_final = add_col .copy ()
1087
+ # properties that are split by time period and category
1088
+ for c in add_col :
1089
+ if "_" not in c :
1090
+ continue
1091
+ # WranglerLogger.debug("Processing Column: {}".format(c))
1092
+ (
1093
+ p_base_name ,
1094
+ p_time_period ,
1095
+ p_category ,
1096
+ managed_lane ,
1097
+ ) = column_name_to_parts (c , self .parameters )
1098
+
1099
+ if p_base_name not in self .parameters .properties_to_split .keys ():
1100
+ continue
1101
+
1102
+ if (p_base_name in cube_add_df .columns ):
1103
+ if cube_add_df [p_base_name ].equals (cube_add_df [c ]):
1104
+ add_col_final .remove (c )
1105
+ continue
1106
+ else :
1107
+ msg = "Detected different changes for split-property variables on regular roadway links: "
1108
+ msg += "conflicting \" {}\" values \" {}\" , \" {}\" " .format (p_base_name , cube_add_df [p_base_name ], cube_add_df [c ])
1109
+ WranglerLogger .error (msg )
1110
+ raise ValueError (msg )
1111
+
1112
+ else :
1113
+ cube_add_df [p_base_name ] = cube_add_df [c ]
1114
+ add_col_final .remove (c )
1115
+ add_col_final .append (p_base_name )
1083
1116
1084
- add_link_properties = cube_add_df [add_col ].to_dict ("records" )
1117
+ add_link_properties = cube_add_df [add_col_final ].to_dict ("records" )
1085
1118
1086
1119
# WranglerLogger.debug("Add Link Properties: {}".format(add_link_properties))
1087
1120
WranglerLogger .debug ("{} Links Added" .format (len (add_link_properties )))
0 commit comments