Skip to content

Commit

Permalink
move class __eq__ to abstract
Browse files Browse the repository at this point in the history
  • Loading branch information
rodolfocarobene committed May 17, 2023
1 parent 0ae8e60 commit b393414
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/qibolab/pulses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand All @@ -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."""
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit b393414

Please sign in to comment.