Skip to content

Commit

Permalink
Refactor individual_velocity_side_view function to simplify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
r.subaih committed Mar 17, 2024
1 parent 4e43015 commit 3b95d93
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions helper/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,15 @@ def individual_velocity_side_view(data: npt.NDArray[np.float64], frame_data: npt
if (ped_data_prev.size != 0) and (ped_data_next.size != 0): # there is frame previous and next
velocity[indx] = (data_frame_next[data_frame_next[:, 0] == ped_id][0][2] -
data_frame_prev[data_frame_prev[:, 0] == ped_id][0][2]) / delta_t
indx += 1
elif (ped_data_prev.size != 0) and (ped_data_next.size == 0): # there is frame previous
velocity[indx] = (frame_data[frame_data[:, 0] == ped_id][0][2] -
data_frame_prev[data_frame_prev[:, 0] == ped_id][0][2]) / delta_t
indx += 1
elif (ped_data_prev.size == 0) and (ped_data_next.size != 0): # there is frame next
velocity[indx] = (data_frame_next[data_frame_next[:, 0] == ped_id][0][2] -
frame_data[frame_data[:, 0] == ped_id][0][2]) / delta_t
indx += 1
elif (ped_data_prev.size == 0) and (ped_data_next.size != 0): # there is no frame previous and next
velocity[indx] = (ped_data_max - ped_data_min) / delta_t
indx += 1
else:
indx += 1
continue

indx += 1
return velocity

def individual_headway_side_view(frame_data: npt.NDArray[np.float64]) -> npt.NDArray[np.float64]:
Expand Down

0 comments on commit 3b95d93

Please sign in to comment.