Skip to content

Commit

Permalink
🎨 Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
MathisFederico committed Dec 14, 2024
1 parent 0902666 commit 673645f
Show file tree
Hide file tree
Showing 36 changed files with 36 additions and 62 deletions.
2 changes: 1 addition & 1 deletion src/hebg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" A structure for explainable hierarchical reinforcement learning """
"""A structure for explainable hierarchical reinforcement learning"""

from hebg.behavior import Behavior
from hebg.heb_graph import HEBGraph
Expand Down
3 changes: 1 addition & 2 deletions src/hebg/behavior.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Module for base Behavior. """
"""Module for base Behavior."""

from __future__ import annotations

Expand All @@ -15,7 +15,6 @@


class Behavior(Node):

"""Abstract class for a Behavior as Node"""

def __init__(self, name: str, image=None) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/hebg/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>
# pylint: disable=protected-access

""" Additional utility functions for networkx graphs. """
"""Additional utility functions for networkx graphs."""

from typing import TYPE_CHECKING, Any, Dict, List

Expand Down
3 changes: 1 addition & 2 deletions src/hebg/heb_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>
# pylint: disable=arguments-differ

""" Module containing the HEBGraph base class. """
"""Module containing the HEBGraph base class."""

from __future__ import annotations

Expand All @@ -24,7 +24,6 @@


class HEBGraph(DiGraph):

"""Base class for Hierchical Explanation of Behavior as Graphs.
An HEBGraph is a DiGraph, and as such stores nodes and directed edges with
Expand Down
2 changes: 1 addition & 1 deletion src/hebg/layouts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Module containing layouts to draw graphs. """
"""Module containing layouts to draw graphs."""

from hebg.layouts.deterministic import staircase_layout
from hebg.layouts.metabased import leveled_layout_energy
Expand Down
2 changes: 1 addition & 1 deletion src/hebg/layouts/deterministic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>
# pylint: disable=protected-access

""" Deterministic layouts """
"""Deterministic layouts"""

import networkx as nx
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion src/hebg/layouts/metabased.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>
# pylint: disable=protected-access

""" Metaheuristics based layouts """
"""Metaheuristics based layouts"""

from copy import deepcopy

Expand Down
2 changes: 1 addition & 1 deletion src/hebg/layouts/metaheuristics.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Metaheuristics used for building layouts """
"""Metaheuristics used for building layouts"""

import numpy as np

Expand Down
2 changes: 1 addition & 1 deletion src/hebg/metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Module containing HEBGraph metrics. """
"""Module containing HEBGraph metrics."""
2 changes: 1 addition & 1 deletion src/hebg/metrics/complexity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Module for complexity computation methods. """
"""Module for complexity computation methods."""

from hebg.metrics.complexity.complexities import general_complexity, learning_complexity

Expand Down
3 changes: 1 addition & 2 deletions src/hebg/metrics/complexity/complexities.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" General complexity. """

"""General complexity."""

from typing import TYPE_CHECKING, Dict, Tuple

Expand Down
2 changes: 1 addition & 1 deletion src/hebg/metrics/complexity/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Utility functions for complexity computation. """
"""Utility functions for complexity computation."""

from copy import deepcopy

Expand Down
2 changes: 1 addition & 1 deletion src/hebg/metrics/histograms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" HEBGraph used nodes histograms computation. """
"""HEBGraph used nodes histograms computation."""

from typing import TYPE_CHECKING, Dict, List, Tuple
from warnings import warn
Expand Down
2 changes: 1 addition & 1 deletion src/hebg/metrics/utility/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Module for utility computation methods. """
"""Module for utility computation methods."""

from hebg.metrics.utility.binary_utility import binary_graphbased_utility

Expand Down
2 changes: 1 addition & 1 deletion src/hebg/metrics/utility/binary_utility.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Simplest binary utility for HEBGraph. """
"""Simplest binary utility for HEBGraph."""

from typing import Dict, List

Expand Down
6 changes: 1 addition & 5 deletions src/hebg/node.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Module for base Node classes. """
"""Module for base Node classes."""

import dis
from typing import Any, List
Expand Down Expand Up @@ -68,7 +68,6 @@ def __repr__(self) -> str:


class Action(Node):

"""Node representing an action in an HEBGraph."""

def __init__(self, action: Any, name: str = None, **kwargs) -> None:
Expand All @@ -84,7 +83,6 @@ def __call__(self, observation: Any) -> Any:


class StochasticAction(Action):

"""Node representing a stochastic choice between actions in an HEBGraph."""

def __init__(
Expand All @@ -99,7 +97,6 @@ def __call__(self, observation):


class FeatureCondition(Node):

"""Node representing a feature condition in an HEBGraph."""

def __init__(self, name: str = None, **kwargs) -> None:
Expand All @@ -110,7 +107,6 @@ def __call__(self, observation: Any) -> int:


class EmptyNode(Node):

"""Node representing an empty node in an HEBGraph."""

def __init__(self, name: str) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/hebg/requirements_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>
# pylint: disable=arguments-differ

""" Module for building underlying requirement graphs based on a set of behaviors. """
"""Module for building underlying requirement graphs based on a set of behaviors."""

from __future__ import annotations

Expand Down
1 change: 1 addition & 0 deletions src/hebg/unrolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Behaviors that do not have a graph (Unexplainable behaviors) should stay as is in the graph.
"""

from copy import copy
from typing import TYPE_CHECKING, Dict, List, Tuple, Optional, Union

Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Tests for the heb_graph package. """
"""Tests for the heb_graph package."""
6 changes: 0 additions & 6 deletions tests/examples/behaviors/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class FundamentalBehavior(Behavior):

"""Fundamental behavior based on an Action."""

def __init__(self, action: Action) -> None:
Expand All @@ -23,7 +22,6 @@ def build_graph(self) -> HEBGraph:


class AA_Behavior(Behavior):

"""Double root fundamental behavior"""

def __init__(self, name: str, any_mode: str) -> None:
Expand All @@ -40,7 +38,6 @@ def build_graph(self) -> HEBGraph:


class F_A_Behavior(Behavior):

"""Single feature condition behavior"""

def __init__(
Expand Down Expand Up @@ -68,7 +65,6 @@ def build_graph(self) -> HEBGraph:


class F_F_A_Behavior(Behavior):

"""Double layer feature conditions behavior"""

def build_graph(self) -> HEBGraph:
Expand All @@ -91,7 +87,6 @@ def build_graph(self) -> HEBGraph:


class F_AA_Behavior(Behavior):

"""Feature condition with mutliple actions on same index."""

def __init__(self, name: str, any_mode: str) -> None:
Expand All @@ -110,7 +105,6 @@ def build_graph(self) -> HEBGraph:


class AF_A_Behavior(Behavior):

"""Double root with feature condition and action"""

def __init__(self, name: str, any_mode: str) -> None:
Expand Down
4 changes: 0 additions & 4 deletions tests/examples/behaviors/basic_empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class E_A_Behavior(Behavior):

"""Empty behavior"""

def __init__(self, name: str, action: Action) -> None:
Expand All @@ -20,7 +19,6 @@ def build_graph(self) -> HEBGraph:


class E_F_A_Behavior(Behavior):

"""Double layer empty then feature conditions behavior"""

def build_graph(self) -> HEBGraph:
Expand All @@ -37,7 +35,6 @@ def build_graph(self) -> HEBGraph:


class F_E_A_Behavior(Behavior):

"""Double layer feature conditions then empty behavior"""

def build_graph(self) -> HEBGraph:
Expand All @@ -57,7 +54,6 @@ def build_graph(self) -> HEBGraph:


class E_E_A_Behavior(Behavior):

"""Double layer empty behavior"""

def build_graph(self) -> HEBGraph:
Expand Down
2 changes: 1 addition & 1 deletion tests/examples/behaviors/binary_sum.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from hebg import Action, Behavior
from hebg import Action
from tests.examples.behaviors import F_A_Behavior
from tests.examples.feature_conditions import IsDivisibleFeatureCondition

Expand Down
3 changes: 3 additions & 0 deletions tests/examples/feature_conditions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
ThresholdFeatureCondition,
IsDivisibleFeatureCondition,
)


__all__ = ["ThresholdFeatureCondition", "IsDivisibleFeatureCondition"]
2 changes: 1 addition & 1 deletion tests/integration/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Integration tests for the heb_graph package. """
"""Integration tests for the heb_graph package."""
2 changes: 1 addition & 1 deletion tests/integration/test_behavior.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Behavior of HEBGraphs when called. """
"""Behavior of HEBGraphs when called."""

import pytest_check as check

Expand Down
3 changes: 1 addition & 2 deletions tests/integration/test_behavior_empty.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Behavior of HEBGraphs with empty nodes. """
"""Behavior of HEBGraphs with empty nodes."""

import pytest_check as check

Expand All @@ -12,7 +12,6 @@
F_E_A_Behavior,
E_E_A_Behavior,
)
from tests.examples.feature_conditions import ThresholdFeatureCondition


def test_e_a_graph():
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_paper_basic_example.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Integration tests for the initial paper examples. """
"""Integration tests for the initial paper examples."""

from typing import Dict, List
from copy import deepcopy
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Unit tests for the heb_graph package. """
"""Unit tests for the heb_graph package."""
2 changes: 1 addition & 1 deletion tests/unit/layouts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Unit tests for the hebg.layouts submodules. """
"""Unit tests for the hebg.layouts submodules."""
2 changes: 1 addition & 1 deletion tests/unit/layouts/test_metaheuristics.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Unit tests for the hebg.metaheuristics module. """
"""Unit tests for the hebg.metaheuristics module."""

import numpy as np

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/metrics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Unit tests for the hebg.metrics module. """
"""Unit tests for the hebg.metrics module."""
2 changes: 1 addition & 1 deletion tests/unit/metrics/complexity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Unit tests for the hebg.metrics.complexity module. """
"""Unit tests for the hebg.metrics.complexity module."""
6 changes: 1 addition & 5 deletions tests/unit/metrics/complexity/test_complexities.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# HEBGraph for explainable hierarchical reinforcement learning
# Copyright (C) 2021-2022 Mathïs FEDERICO <https://www.gnu.org/licenses/>

""" Integration tests for the hebg.metrics.complexity.complexities module. """
"""Integration tests for the hebg.metrics.complexity.complexities module."""

import pytest
import pytest_check as check

from hebg.metrics.complexity.complexities import learning_complexity
from hebg import Action, Behavior, FeatureCondition


class TestComplexities:
Expand Down
Loading

0 comments on commit 673645f

Please sign in to comment.