From b39341467e6dcf3dd439e8d71a70616d9a72a797 Mon Sep 17 00:00:00 2001 From: rodolfocarobene Date: Wed, 17 May 2023 16:24:14 +0400 Subject: [PATCH] move class __eq__ to abstract --- src/qibolab/pulses.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/qibolab/pulses.py b/src/qibolab/pulses.py index 8b87fe386..7a3480ba5 100644 --- a/src/qibolab/pulses.py +++ b/src/qibolab/pulses.py @@ -167,6 +167,10 @@ def modulated_waveforms(self): modulated_waveform_q.serial = f"Modulated_Waveform_Q(num_samples = {num_samples}, amplitude = {format(pulse.amplitude, '.6f').rstrip('0').rstrip('.')}, shape = {str(pulse.shape)}, frequency = {format(pulse.frequency, '_')}, phase = {format(global_phase + pulse.relative_phase, '.6f').rstrip('0').rstrip('.')})" return (modulated_waveform_i, modulated_waveform_q) + def __eq__(self, item) -> bool: + """Overloads == operator""" + return type(item) is self.__class__ + class Rectangular(PulseShape): """ @@ -178,10 +182,6 @@ def __init__(self): self.name = "Rectangular" self.pulse: Pulse = None - def __eq__(self, item) -> bool: - """Overloads == operator""" - return type(item) is Rectangular - @property def envelope_waveform_i(self) -> Waveform: """The envelope waveform of the i component of the pulse.""" @@ -233,7 +233,7 @@ def __init__(self, rel_sigma: float): def __eq__(self, item) -> bool: """Overloads == operator""" - if type(item) is Gaussian: + if super().__eq__(item): return self.rel_sigma == item.rel_sigma return False @@ -293,7 +293,7 @@ def __init__(self, rel_sigma, beta): def __eq__(self, item) -> bool: """Overloads == operator""" - if type(item) is Drag: + if super().__eq__(item): return self.rel_sigma == item.rel_sigma and self.beta == item.beta return False @@ -368,7 +368,7 @@ def __init__(self, b, a, target: PulseShape): def __eq__(self, item) -> bool: """Overloads == operator""" - if type(item) is IIR: + if super().__eq__(item): return self.target == item.target and (self.a == item.a).all() and (self.b == item.b).all() return False @@ -446,7 +446,7 @@ def __init__(self, t_half_flux_pulse=None, b_amplitude=1): def __eq__(self, item) -> bool: """Overloads == operator""" - if type(item) is SNZ: + if super().__eq__(item): return self.t_half_flux_pulse == item.t_half_flux_pulse and self.b_amplitude == item.b_amplitude return False @@ -515,7 +515,7 @@ def __init__(self, alpha: float): def __eq__(self, item) -> bool: """Overloads == operator""" - if type(item) is eCap: + if super().__eq__(item): return self.alpha == item.alpha return False