From b44c9c26c94353fa8c0d05425bc3fcca565b5215 Mon Sep 17 00:00:00 2001 From: u214892 <u214892@sbb.ch> Date: Thu, 13 Jun 2019 11:13:31 +0200 Subject: [PATCH] fix flake8 --- flatland/envs/env_utils.py | 1 + flatland/envs/observations.py | 2 -- flatland/utils/graphics_layer.py | 3 +-- flatland/utils/graphics_pil.py | 3 ++- flatland/utils/rendertools.py | 27 +++++++++++++-------------- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/flatland/envs/env_utils.py b/flatland/envs/env_utils.py index 4d350178..9d1aa52e 100644 --- a/flatland/envs/env_utils.py +++ b/flatland/envs/env_utils.py @@ -94,6 +94,7 @@ def coordinate_to_position(width, coords): position.append((t[1] * width + t[0])) return np.array(position) + class AStarNode(): """A node class for A* Pathfinding""" diff --git a/flatland/envs/observations.py b/flatland/envs/observations.py index 8775b9d8..a6bb5f2f 100644 --- a/flatland/envs/observations.py +++ b/flatland/envs/observations.py @@ -173,12 +173,10 @@ class TreeObsForRailEnv(ObservationBuilder): in the `handles' list. """ - if self.predictor: self.predictions = self.predictor.get() pred_pos = np.concatenate([[x[:, 1:3]] for x in list(self.predictions.values())], axis=0) pred_pos = list(map(list, zip(*pred_pos))) - pred_dir = [x[:, 2] for x in list(self.predictions.values())] observations = {} for h in handles: diff --git a/flatland/utils/graphics_layer.py b/flatland/utils/graphics_layer.py index d00d8b3e..ed92249c 100644 --- a/flatland/utils/graphics_layer.py +++ b/flatland/utils/graphics_layer.py @@ -82,6 +82,5 @@ class GraphicsLayer(object): def resize(self, env): pass - - def build_background_map(self,dTargets): + def build_background_map(self, dTargets): pass diff --git a/flatland/utils/graphics_pil.py b/flatland/utils/graphics_pil.py index 33e1b133..534b1378 100644 --- a/flatland/utils/graphics_pil.py +++ b/flatland/utils/graphics_pil.py @@ -363,7 +363,8 @@ class PILSVG(PILGL): # Load the target files (which have rails and transitions of their own) # They are indexed by (binTrans, iAgent), ie a tuple of the binary transition and the agent index - dPilRail2 = self.loadSVGs(dTargetFiles, rotate=False, agent_colors=self.ltAgentColors, backgroundImage="Background_rail.svg", + dPilRail2 = self.loadSVGs(dTargetFiles, rotate=False, agent_colors=self.ltAgentColors, + backgroundImage="Background_rail.svg", whitefilter="Background_white_filter.svg") # Merge them with the regular rails. # https://stackoverflow.com/questions/38987/how-to-merge-two-dictionaries-in-a-single-expression diff --git a/flatland/utils/rendertools.py b/flatland/utils/rendertools.py index 937580f4..9b04f9c1 100644 --- a/flatland/utils/rendertools.py +++ b/flatland/utils/rendertools.py @@ -47,7 +47,6 @@ class RenderTool(object): self.new_rail = True self.update_background() - def update_background(self): # create background map dTargets = {} @@ -509,19 +508,19 @@ class RenderTool(object): ) def renderEnv(self, - show=False, # whether to call matplotlib show() or equivalent after completion - # use false when calling from Jupyter. (and matplotlib no longer supported!) - curves=True, # draw turns as curves instead of straight diagonal lines - spacing=False, # defunct - size of spacing between rails - arrows=False, # defunct - draw arrows on rail lines - agents=True, # whether to include agents - show_observations=True, # whether to include observations - sRailColor="gray", # color to use in drawing rails (not used with SVG) - frames=False, # frame counter to show (intended since invocation) - iEpisode=None, # int episode number to show - iStep=None, # int step number to show in image - iSelectedAgent=None, # indicate which agent is "selected" in the editor - action_dict=None): # defunct - was used to indicate agent intention to turn + show=False, # whether to call matplotlib show() or equivalent after completion + # use false when calling from Jupyter. (and matplotlib no longer supported!) + curves=True, # draw turns as curves instead of straight diagonal lines + spacing=False, # defunct - size of spacing between rails + arrows=False, # defunct - draw arrows on rail lines + agents=True, # whether to include agents + show_observations=True, # whether to include observations + sRailColor="gray", # color to use in drawing rails (not used with SVG) + frames=False, # frame counter to show (intended since invocation) + iEpisode=None, # int episode number to show + iStep=None, # int step number to show in image + iSelectedAgent=None, # indicate which agent is "selected" in the editor + action_dict=None): # defunct - was used to indicate agent intention to turn """ Draw the environment using the GraphicsLayer this RenderTool was created with. (Use show=False from a Jupyter notebook with %matplotlib inline) """ -- GitLab