From 941dcde197abcb0c3ea7202bb649b56623796576 Mon Sep 17 00:00:00 2001 From: Erik Nygren <erik.nygren@sbb.ch> Date: Sat, 31 Aug 2019 19:58:29 -0400 Subject: [PATCH] fixed formatting --- flatland/envs/rail_generators.py | 1 - flatland/envs/schedule_generators.py | 5 ++--- flatland/evaluators/client.py | 2 -- flatland/utils/simple_rail.py | 7 ++++--- tests/test_flatland_core_transition_map.py | 8 ++++---- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/flatland/envs/rail_generators.py b/flatland/envs/rail_generators.py index d915fdc7..1b72b978 100644 --- a/flatland/envs/rail_generators.py +++ b/flatland/envs/rail_generators.py @@ -581,7 +581,6 @@ def sparse_rail_generator(num_cities=5, num_intersections=4, num_trainstations=2 to_close = True tries = 0 - if not realistic_mode: while to_close: x_tmp = node_radius + np.random.randint(height - node_radius) diff --git a/flatland/envs/schedule_generators.py b/flatland/envs/schedule_generators.py index 8d1a04d0..ee80320b 100644 --- a/flatland/envs/schedule_generators.py +++ b/flatland/envs/schedule_generators.py @@ -194,7 +194,8 @@ def random_schedule_generator(speed_ratio_map: Mapping[float, float] = None) -> if len(valid_starting_directions) == 0: update_agents[i] = 1 - warnings.warn("reset position for agent[{}]: {} -> {}".format(i, agents_position[i], agents_target[i])) + warnings.warn( + "reset position for agent[{}]: {} -> {}".format(i, agents_position[i], agents_target[i])) re_generate = True break else: @@ -229,7 +230,6 @@ def schedule_from_file(filename) -> ScheduleGenerator: # agents are always reset as not moving agents_static = [EnvAgentStatic(d[0], d[1], d[2], d[3], d[4], d[5]) for d in data["agents_static"]] - # setup with loaded data agents_position = [a.position for a in agents_static] agents_direction = [a.direction for a in agents_static] @@ -239,4 +239,3 @@ def schedule_from_file(filename) -> ScheduleGenerator: return agents_position, agents_direction, agents_target, agents_speed, agents_malfunction return generator - diff --git a/flatland/evaluators/client.py b/flatland/evaluators/client.py index f2dac1c8..92f1a49d 100644 --- a/flatland/evaluators/client.py +++ b/flatland/evaluators/client.py @@ -254,14 +254,12 @@ class FlatlandRemoteClient(object): if __name__ == "__main__": remote_client = FlatlandRemoteClient() - def my_controller(obs, _env): _action = {} for _idx, _ in enumerate(_env.agents): _action[_idx] = np.random.randint(0, 5) return _action - my_observation_builder = TreeObsForRailEnv(max_depth=3, predictor=ShortestPathPredictorForRailEnv()) diff --git a/flatland/utils/simple_rail.py b/flatland/utils/simple_rail.py index 67bd93dd..f9f1009d 100644 --- a/flatland/utils/simple_rail.py +++ b/flatland/utils/simple_rail.py @@ -81,6 +81,7 @@ def make_simple_rail2() -> Tuple[GridTransitionMap, np.array]: rail.grid = rail_map return rail, rail_map + def make_simple_rail_unconnected() -> Tuple[GridTransitionMap, np.array]: # We instantiate a very simple rail network on a 7x10 grid: # Note that that cells have invalid RailEnvTransitions! @@ -107,9 +108,9 @@ def make_simple_rail_unconnected() -> Tuple[GridTransitionMap, np.array]: simple_switch_east_west_south = transitions.rotate_transition(simple_switch_north_left, 270) rail_map = np.array( [[empty] * 3 + [dead_end_from_south] + [empty] * 6] + - [[empty] * 3 + [vertical_straight] + [empty] * 6] + - [[empty] * 3 + [dead_end_from_north] + [empty] * 6] + - [[dead_end_from_east] + [horizontal_straight] * 5 + [simple_switch_east_west_south] + + [[empty] * 3 + [vertical_straight] + [empty] * 6] + + [[empty] * 3 + [dead_end_from_north] + [empty] * 6] + + [[dead_end_from_east] + [horizontal_straight] * 5 + [simple_switch_east_west_south] + [horizontal_straight] * 2 + [dead_end_from_west]] + [[empty] * 6 + [vertical_straight] + [empty] * 3] * 2 + [[empty] * 6 + [dead_end_from_north] + [empty] * 3], dtype=np.uint16) diff --git a/tests/test_flatland_core_transition_map.py b/tests/test_flatland_core_transition_map.py index 8812c847..1137b881 100644 --- a/tests/test_flatland_core_transition_map.py +++ b/tests/test_flatland_core_transition_map.py @@ -116,18 +116,18 @@ def test_path_exists(rendering=False): check_path( env, rail, - (1,3), # east dead-end + (1, 3), # east dead-end 2, # south - (3,3), # north dead-end + (3, 3), # north dead-end True ) check_path( env, rail, - (1,3), # east dead-end + (1, 3), # east dead-end 0, # north - (3,3), # north dead-end + (3, 3), # north dead-end True ) -- GitLab