Skip to content

Commit

Permalink
Checked for edge case where vehicle speeds is empty (#795)
Browse files Browse the repository at this point in the history
  • Loading branch information
sftwre authored and AboudyKreidieh committed Dec 18, 2019
1 parent 97b962a commit ac23278
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion flow/visualize/visualizer_rllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ def visualizer_rllib(args):
ret = 0
for _ in range(env_params.horizon):
vehicles = env.unwrapped.k.vehicle
vel.append(np.mean(vehicles.get_speed(vehicles.get_ids())))
speeds = vehicles.get_speed(vehicles.get_ids())

# only include non-empty speeds
if speeds:
vel.append(np.mean(speeds))

if multiagent:
action = {}
for agent_id in state.keys():
Expand Down

0 comments on commit ac23278

Please sign in to comment.