From 8b14ad6da1bdde6536335c46d053c18006a65c12 Mon Sep 17 00:00:00 2001
From: angloth <angus.lothian@hotmail.com>
Date: Thu, 27 Feb 2020 18:08:54 +0100
Subject: [PATCH] Remove old code and fix imports and typing to make code
 runnable

---
 b_asic/core_operations.py   | 10 +++++-----
 b_asic/graph_id.py          |  9 +++++----
 b_asic/signal_flow_graph.py |  5 +++--
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/b_asic/core_operations.py b/b_asic/core_operations.py
index 08c95261..744e3768 100644
--- a/b_asic/core_operations.py
+++ b/b_asic/core_operations.py
@@ -4,7 +4,7 @@ TODO: More info.
 """
 
 from b_asic.port import InputPort, OutputPort
-from b_asic.operation import OperationId, Operation
+from b_asic.operation import Operation
 from b_asic.basic_operation import BasicOperation
 from b_asic.graph_id import GraphIDType
 from numbers import Number
@@ -26,7 +26,7 @@ class Constant(BasicOperation):
 	TODO: More info.
 	"""
 
-	def __init__(self, identifier: OperationId, value: Number):
+	def __init__(self, value: Number):
 		"""
 		Construct a Constant.
 		"""
@@ -46,11 +46,11 @@ class Addition(BasicOperation):
 	TODO: More info.
 	"""
 
-	def __init__(self, identifier: OperationId):
+	def __init__(self):
 		"""
 		Construct an Addition.
 		"""
-		super().__init__(identifier)
+		super().__init__(self)
 		self._input_ports = [InputPort(1), InputPort(1)] # TODO: Generate appropriate ID for ports.
 		self._output_ports = [OutputPort(1)] # TODO: Generate appropriate ID for ports.
 
@@ -67,7 +67,7 @@ class ConstantMultiplication(BasicOperation):
 	TODO: More info.
 	"""
 
-	def __init__(self, identifier: OperationId, coefficient: Number):
+	def __init__(self, coefficient: Number):
 		"""
 		Construct a ConstantMultiplication.
 		"""
diff --git a/b_asic/graph_id.py b/b_asic/graph_id.py
index fa099d92..9eba69f5 100644
--- a/b_asic/graph_id.py
+++ b/b_asic/graph_id.py
@@ -14,7 +14,7 @@ class GraphIDGenerator:
     A class that generates Graph IDs for objects. 
     """
 
-    _next_id_number: DefaultDict(GraphIDType, GraphIDNumber)
+    _next_id_number: DefaultDict[GraphIDType, GraphIDNumber]
 
     def __init__(self):
         self._next_id_number = defaultdict(lambda: 1)       # Initalises every key element to 1
@@ -46,7 +46,7 @@ class GraphID:
 
 
     def __str__(self) -> str:
-        return graph_id_type + str(graph_id_number)
+        return self.graph_id_type + str(self.graph_id_number)
 
 
     def __repr__(self) -> str:
@@ -57,12 +57,13 @@ class GraphID:
         return hash(str(self))
 
 
-    def __eq__(self, other: GraphID) -> bool:
+    def __eq__(self, other: object) -> bool:
+        assert isinstance(other, GraphID), "Other object not an instance of GraphID"
         return self.graph_id_type == other.graph_id_type and \
             self.graph_id_number == other.graph_id_number
 
     
-    def get_next_id(self) -> GraphID:
+    def get_next_id(self) -> 'GraphID':
         """
         Returns a new GraphID of the same type with an incremented id number.
         """ 
diff --git a/b_asic/signal_flow_graph.py b/b_asic/signal_flow_graph.py
index c87c4129..cbc29fa2 100644
--- a/b_asic/signal_flow_graph.py
+++ b/b_asic/signal_flow_graph.py
@@ -7,8 +7,9 @@ from b_asic.operation import Operation
 from b_asic.basic_operation import BasicOperation
 from b_asic.signal import Signal, SignalSource, SignalDestination
 from b_asic.simulation import SimulationState, OperationState
+from b_asic.graph_id import GraphIDGenerator, GraphID
+
 from typing import List, Dict, Union
-from graph_id import GraphIDGenerator, GraphID
 
 
 class SFG(BasicOperation):
@@ -17,7 +18,7 @@ class SFG(BasicOperation):
 	TODO: More info.
 	"""
 
-	_graph_objects: Dict(GraphID, Union(Operation, Signal))
+	_graph_objects: Dict[GraphID, Union[Operation, Signal]]
 	_graph_id_generator: GraphIDGenerator
 
 	def __init__(self, input_destinations: List[SignalDestination], output_sources: List[SignalSource]):
-- 
GitLab