From a5ebb627434252550df0145da6c4b5aa9de25b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Math=C3=AFs=20F=C3=A9d=C3=A9rico?= Date: Fri, 3 Feb 2023 19:43:04 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Isort=20+=20black?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hebg/__init__.py | 2 +- src/hebg/codegen.py | 7 +++---- src/hebg/draw.py | 18 ++++++++---------- src/hebg/heb_graph.py | 11 ++++------- src/hebg/metrics/complexity/complexities.py | 2 +- src/hebg/metrics/histograms.py | 3 +-- src/hebg/requirements_graph.py | 6 +++--- src/hebg/unrolling.py | 2 +- 8 files changed, 22 insertions(+), 29 deletions(-) diff --git a/src/hebg/__init__.py b/src/hebg/__init__.py index fdb5bb3..a54488a 100644 --- a/src/hebg/__init__.py +++ b/src/hebg/__init__.py @@ -3,7 +3,7 @@ """ A structure for explainable hierarchical reinforcement learning """ +from hebg.behavior import Behavior from hebg.heb_graph import HEBGraph from hebg.node import Action, EmptyNode, FeatureCondition, Node, StochasticAction -from hebg.behavior import Behavior from hebg.requirements_graph import build_requirement_graph diff --git a/src/hebg/codegen.py b/src/hebg/codegen.py index 25f504b..b58987d 100644 --- a/src/hebg/codegen.py +++ b/src/hebg/codegen.py @@ -1,14 +1,13 @@ """Module for code generation from HEBGraph.""" from re import sub +from typing import TYPE_CHECKING, Dict, List, Set, Tuple -from typing import TYPE_CHECKING, List, Dict, Set, Tuple - -from hebg.node import Node, Action, FeatureCondition from hebg.behavior import Behavior -from hebg.unrolling import BEHAVIOR_SEPARATOR from hebg.graph import get_roots, get_successors_with_index from hebg.metrics.histograms import cumulated_hebgraph_histogram +from hebg.node import Action, FeatureCondition, Node +from hebg.unrolling import BEHAVIOR_SEPARATOR if TYPE_CHECKING: from hebg.heb_graph import HEBGraph diff --git a/src/hebg/draw.py b/src/hebg/draw.py index 55d8e32..3b407e0 100644 --- a/src/hebg/draw.py +++ b/src/hebg/draw.py @@ -1,24 +1,22 @@ import math from typing import TYPE_CHECKING, Dict, Optional, Tuple -import numpy as np -from scipy.spatial import ConvexHull # pylint: disable=no-name-in-module - -import matplotlib.pyplot as plt import matplotlib.patches as mpatches -from matplotlib.legend_handler import HandlerPatch -from matplotlib.legend import Legend +import matplotlib.pyplot as plt +import numpy as np from matplotlib.axes import Axes - +from matplotlib.legend import Legend +from matplotlib.legend_handler import HandlerPatch from networkx import draw_networkx_edges +from scipy.spatial import ConvexHull # pylint: disable=no-name-in-module -from hebg.unrolling import group_behaviors_points -from hebg.layouts import staircase_layout from hebg.graph import draw_networkx_nodes_images +from hebg.layouts import staircase_layout +from hebg.unrolling import group_behaviors_points if TYPE_CHECKING: - from hebg.node import Node from hebg.heb_graph import HEBGraph + from hebg.node import Node def draw_hebgraph( diff --git a/src/hebg/heb_graph.py b/src/hebg/heb_graph.py index 7c29b70..3204967 100644 --- a/src/hebg/heb_graph.py +++ b/src/hebg/heb_graph.py @@ -6,21 +6,18 @@ from __future__ import annotations -from typing import Any, Dict, List, Tuple, Optional +from typing import Any, Dict, List, Optional, Tuple import numpy as np from matplotlib.axes import Axes - from networkx import DiGraph - -from hebg.graph import get_roots, get_successors_with_index +from hebg.behavior import Behavior from hebg.codegen import get_hebg_source -from hebg.unrolling import unroll_graph from hebg.draw import draw_hebgraph - +from hebg.graph import get_roots, get_successors_with_index from hebg.node import Node -from hebg.behavior import Behavior +from hebg.unrolling import unroll_graph class HEBGraph(DiGraph): diff --git a/src/hebg/metrics/complexity/complexities.py b/src/hebg/metrics/complexity/complexities.py index 37aa445..8caeb78 100644 --- a/src/hebg/metrics/complexity/complexities.py +++ b/src/hebg/metrics/complexity/complexities.py @@ -6,9 +6,9 @@ from typing import TYPE_CHECKING, Dict, Tuple +from hebg.behavior import Behavior from hebg.metrics.complexity.utils import update_sum_dict from hebg.node import Action -from hebg.behavior import Behavior if TYPE_CHECKING: from hebg.node import Node diff --git a/src/hebg/metrics/histograms.py b/src/hebg/metrics/histograms.py index 46d447a..7c17ed4 100644 --- a/src/hebg/metrics/histograms.py +++ b/src/hebg/metrics/histograms.py @@ -8,9 +8,8 @@ import numpy as np - -from hebg.metrics.complexity.utils import update_sum_dict from hebg.behavior import Behavior +from hebg.metrics.complexity.utils import update_sum_dict from hebg.node import Action, FeatureCondition if TYPE_CHECKING: diff --git a/src/hebg/requirements_graph.py b/src/hebg/requirements_graph.py index dd6a82c..6e0d9d4 100644 --- a/src/hebg/requirements_graph.py +++ b/src/hebg/requirements_graph.py @@ -7,14 +7,14 @@ from __future__ import annotations from copy import deepcopy -from typing import List, Dict +from typing import Dict, List from networkx import DiGraph, descendants -from hebg.heb_graph import HEBGraph +from hebg.behavior import Behavior from hebg.graph import compute_levels +from hebg.heb_graph import HEBGraph from hebg.node import EmptyNode -from hebg.behavior import Behavior def build_requirement_graph(behaviors: List[Behavior]) -> DiGraph: diff --git a/src/hebg/unrolling.py b/src/hebg/unrolling.py index 3d6383e..16c3af5 100644 --- a/src/hebg/unrolling.py +++ b/src/hebg/unrolling.py @@ -9,9 +9,9 @@ from networkx import relabel_nodes -from hebg.node import Node from hebg.behavior import Behavior from hebg.graph import compute_levels +from hebg.node import Node BEHAVIOR_SEPARATOR = ">"