Skip to content

Commit

Permalink
Flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenevinitsky committed Mar 20, 2020
1 parent 2183ca5 commit 8fe8493
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
4 changes: 1 addition & 3 deletions examples/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,18 +175,16 @@ def on_episode_end(info):
episode = info["episode"]
env = info["env"].get_unwrapped()[0]
avg_speed = np.mean(episode.user_data["avg_speed"])
avg_energy = np.mean(episode.user_data["avg_energy"])
avg_energy = np.mean(episode.user_data["energy"])

episode.custom_metrics["avg_speed"] = avg_speed
episode.custom_metrics["avg_energy"] = avg_energy
episode.custom_metrics["outflow"] = env.k.vehicle.get_outflow_rate()


config["callbacks"] = {"on_episode_start": tune.function(on_episode_start),
"on_episode_step": tune.function(on_episode_step),
"on_episode_end": tune.function(on_episode_end)}


# save the flow params for replay
flow_json = json.dumps(
flow_params, cls=FlowParamsEncoder, sort_keys=True, indent=4)
Expand Down
1 change: 0 additions & 1 deletion flow/utils/rllib.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""
from copy import deepcopy
import json
import sys
import os
import sys

Expand Down
4 changes: 2 additions & 2 deletions tests/fast_tests/test_rewards.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ def test_energy_consumption(self):

# change the speed of one vehicle
env.k.vehicle.test_set_speed("test_0", 1)
self.assertEqual(energy_consumption(env), -12.059337750000001)
self.assertEqual(energy_consumption(env), -1.205933775)

# check that stepping change the previous speeds and increases the energy consumption
env.step(rl_actions=None)
env.step(rl_actions=None)
self.assertGreater(env.k.vehicle.get_previous_speed("test_0"), 0.0)
self.assertLess(energy_consumption(env), -12.059337750000001)
self.assertLess(energy_consumption(env), -1.205933775)

def test_boolean_action_penalty(self):
"""Test the boolean_action_penalty method."""
Expand Down

0 comments on commit 8fe8493

Please sign in to comment.