From e5471b01c0625c13463d64d54262b7b380e7361a Mon Sep 17 00:00:00 2001 From: Lukas Prediger Date: Mon, 23 Apr 2018 11:41:40 +0200 Subject: [PATCH] Fix: hardware.setup._SingleChannel.__eq__ __eq__ function does not use __hash__ anymore. Instead it uses the tuple used in __hash__ directly. --- qctoolkit/hardware/setup.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/qctoolkit/hardware/setup.py b/qctoolkit/hardware/setup.py index e28e30593..2ab1170a4 100644 --- a/qctoolkit/hardware/setup.py +++ b/qctoolkit/hardware/setup.py @@ -1,4 +1,4 @@ -from typing import NamedTuple, Set, Callable, Dict, Tuple, Union, Iterable +from typing import NamedTuple, Set, Callable, Dict, Tuple, Union, Iterable, Any from collections import defaultdict, deque import warnings @@ -33,11 +33,16 @@ def __init__(self, awg: AWG, channel_on_awg: int): self.channel_on_awg = channel_on_awg """The channel's index(starting with 0) on the AWG.""" + @property + def compare_key(self) -> Tuple[Any]: + return (id(self.awg), self.channel_on_awg, type(self)) + def __hash__(self): - return hash((id(self.awg), self.channel_on_awg, type(self))) + return hash(self.compare_key) def __eq__(self, other): - return hash(self) == hash(other) + if not isinstance(other, _SingleChannel): return False + return self.compare_key == other.compare_key class PlaybackChannel(_SingleChannel):