make nodes and lines hashable again
This commit is contained in:
1 parent
0251d66d28
commit
c3e4090f31
1 file changed
+9
-1
@@ -100,10 +100,15 @@ class Node:
|
||||
self.circuit = None
|
||||
|
||||
def __eq__(self, other):
|
||||
"""Checks equality of node name and kind. Does not check pin connections.
|
||||
"""Checks equality of node name and kind. Does not check pin connections.
|
||||
|
||||
This is ok, because (name, kind) is unique within a circuit.
|
||||
"""
|
||||
return self.name == other.name and self.kind == other.kind
|
||||
|
||||
def __hash__(self):
|
||||
return hash((self.name, self.kind))
|
||||
|
||||
|
||||
class Line:
|
||||
"""A line is a directional 1:1 connection between two nodes.
|
||||
@@ -181,6 +186,9 @@ class Line:
|
||||
return self.driver == other.driver and self.driver_pin == other.driver_pin and \
|
||||
self.reader == other.reader and self.reader_pin == other.reader_pin
|
||||
|
||||
def __hash__(self):
|
||||
return hash((self.driver, self.driver_pin, self.reader, self.reader_pin))
|
||||
|
||||
|
||||
class Circuit:
|
||||
"""A Circuit is a container for interconnected nodes and lines.
|
||||
|
||||
Reference in new issue
Block a user