From e3a5813e987851235fe2d355cf127f697ec40bd0 Mon Sep 17 00:00:00 2001 From: Alessandro Candido Date: Fri, 19 Jan 2024 19:31:33 +0100 Subject: [PATCH] Replace waveform hash, since NumPy array are unhashable (because mutable) --- src/qibolab/instruments/qm/config.py | 2 +- tests/test_instruments_qm.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/qibolab/instruments/qm/config.py b/src/qibolab/instruments/qm/config.py index f87a6346b9..2f3bfc5a74 100644 --- a/src/qibolab/instruments/qm/config.py +++ b/src/qibolab/instruments/qm/config.py @@ -332,7 +332,7 @@ def register_waveform(self, pulse, mode="i"): self.waveforms[serial] = {"type": "constant", "sample": pulse.amplitude} else: waveform = getattr(pulse, f"envelope_waveform_{mode}")(SAMPLING_RATE) - serial = hash(waveform) + serial = hash(waveform.tobytes()) if serial not in self.waveforms: self.waveforms[serial] = { "type": "arbitrary", diff --git a/tests/test_instruments_qm.py b/tests/test_instruments_qm.py index b344e08bf4..6caf5c239f 100644 --- a/tests/test_instruments_qm.py +++ b/tests/test_instruments_qm.py @@ -285,8 +285,8 @@ def test_qmopx_register_pulse(dummy_qrc, pulse_type, qubit): "operation": "control", "length": pulse.duration, "waveforms": { - "I": hash(pulse.envelope_waveform_i()), - "Q": hash(pulse.envelope_waveform_q()), + "I": hash(pulse.envelope_waveform_i().tobytes()), + "Q": hash(pulse.envelope_waveform_q().tobytes()), }, }