From a80c8c017fe3e638276f64b516b50bf2f8227780 Mon Sep 17 00:00:00 2001 From: "niehues.mark@gmail.com" <niehues.mark@gmail.com> Date: Thu, 19 Mar 2020 18:34:07 +0100 Subject: [PATCH] remove relative imports --- evrouting/T.py | 1 - evrouting/charge/T.py | 2 +- evrouting/charge/factories.py | 6 +++--- evrouting/charge/routing.py | 7 +++---- evrouting/charge/utils.py | 6 ++---- evrouting/utils.py | 3 +-- tests/config.py | 1 - 7 files changed, 10 insertions(+), 16 deletions(-) diff --git a/evrouting/T.py b/evrouting/T.py index 6c19201..a72149b 100644 --- a/evrouting/T.py +++ b/evrouting/T.py @@ -1,4 +1,3 @@ -from dataclasses import dataclass from typing import Tuple, Union, NewType, Dict, Any Node = int diff --git a/evrouting/charge/T.py b/evrouting/charge/T.py index 2e813cb..82f4c5a 100644 --- a/evrouting/charge/T.py +++ b/evrouting/charge/T.py @@ -126,7 +126,7 @@ class ChargingFunction: if soc > capacity: # Return max charge time return capacity / c - elif soc < 0: + if soc < 0: # Return min charge time return 0 diff --git a/evrouting/charge/factories.py b/evrouting/charge/factories.py index 31a4ead..7131324 100644 --- a/evrouting/charge/factories.py +++ b/evrouting/charge/factories.py @@ -2,9 +2,9 @@ from typing import Dict import networkx as nx -from .T import SoCProfile, SoCFunction, ChargingFunction, Label -from ..T import Node, SoC, Time -from ..graph_tools import charging_cofficient, consumption +from evrouting.T import Node, SoC +from evrouting.graph_tools import charging_cofficient, consumption +from evrouting.charge.T import SoCProfile, SoCFunction, ChargingFunction, Label class SoCProfileFactory: diff --git a/evrouting/charge/routing.py b/evrouting/charge/routing.py index 247bb1a..713b637 100644 --- a/evrouting/charge/routing.py +++ b/evrouting/charge/routing.py @@ -4,16 +4,15 @@ from math import inf import networkx as nx from evrouting.T import Node, SoC from evrouting.utils import PriorityQueue +from evrouting.graph_tools import distance +from evrouting.charge.T import SoCFunction, Label +from evrouting.charge.utils import LabelPriorityQueue, keys from evrouting.charge.factories import ( ChargingFunctionMap, SoCFunctionFactory, SoCProfileFactory ) -from ..graph_tools import distance -from .T import SoCFunction, Label -from .utils import LabelPriorityQueue, keys - def shortest_path(G: nx.Graph, charging_stations: set, s: Node, t: Node, initial_soc: SoC, final_soc: SoC, capacity: SoC): diff --git a/evrouting/charge/utils.py b/evrouting/charge/utils.py index 19e405d..072eade 100644 --- a/evrouting/charge/utils.py +++ b/evrouting/charge/utils.py @@ -1,11 +1,9 @@ from typing import Any, Dict, List -from math import inf from evrouting.utils import PriorityQueue from evrouting.T import SoC, Time - -from .T import Label, SoCFunction -from .factories import SoCFunctionFactory +from evrouting.charge.T import Label, SoCFunction +from evrouting.charge.factories import SoCFunctionFactory class LabelPriorityQueue(PriorityQueue): diff --git a/evrouting/utils.py b/evrouting/utils.py index 46baaa9..b9127d3 100644 --- a/evrouting/utils.py +++ b/evrouting/utils.py @@ -45,8 +45,7 @@ class PriorityQueue: item = self.pq[0][-1] if item is not self.REMOVED: return item - else: - heappop(self.pq) + heappop(self.pq) raise KeyError('Empty queue.') def __bool__(self) -> bool: diff --git a/tests/config.py b/tests/config.py index 51f4617..b8a730c 100644 --- a/tests/config.py +++ b/tests/config.py @@ -1,5 +1,4 @@ import networkx as nx -from copy import copy from typing import Set from evrouting.T import Node, ChargingCoefficient -- GitLab