Skip to content

Commit

Permalink
Mock frozen dataclass hash for Pulse
Browse files Browse the repository at this point in the history
  • Loading branch information
alecandido committed Jan 17, 2024
1 parent ff3309f commit 1cf9dc9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/qibolab/pulses.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class Waveform:
Attributes:
data (np.ndarray): a numpy array containing the samples.
serial (str): a string that can be used as a lable to identify the waveform. It is not automatically
generated, it must be set by the user.
"""

DECIMALS = 5
Expand Down Expand Up @@ -758,6 +756,17 @@ def __post_init__(self):
# TODO: drop the cyclic reference
self.shape.pulse = self

def __hash__(self):
"""Return hash(self).
.. todo::
this has to be replaced by turning :cls:`Pulse` into a _frozen_ dataclass
"""
return hash(
tuple(getattr(self, f.name) for f in fields(self) if f.name != "shape")
)

@property
def finish(self) -> Optional[int]:
"""Time when the pulse is scheduled to finish."""
Expand Down

0 comments on commit 1cf9dc9

Please sign in to comment.