From 9b0e086bd4c24e0d8fa410171d36e6557b3e82b7 Mon Sep 17 00:00:00 2001 From: Simon Humpohl Date: Thu, 1 Dec 2022 15:34:03 +0100 Subject: [PATCH 1/3] Add regression tests --- tests/_program/waveforms_tests.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/_program/waveforms_tests.py b/tests/_program/waveforms_tests.py index e4930372b..d84b2c763 100644 --- a/tests/_program/waveforms_tests.py +++ b/tests/_program/waveforms_tests.py @@ -555,6 +555,31 @@ def test_validate_input_errors(self): TableWaveformEntry(-0.2, 0.2, HoldInterpolationStrategy()), TableWaveformEntry(0.1, 0.2, HoldInterpolationStrategy())]) + def test_validate_input_const_detection(self): + constant_table = [TableWaveformEntry(0.0, 2.5, HoldInterpolationStrategy()), + (1.4, 2.5, LinearInterpolationStrategy())] + linear_table = [TableWaveformEntry(0.0, 0.0, HoldInterpolationStrategy()), + TableWaveformEntry(1.4, 2.5, LinearInterpolationStrategy())] + + self.assertEqual((1.4, 2.5), TableWaveform._validate_input(constant_table)) + self.assertEqual(linear_table, + TableWaveform._validate_input(linear_table)) + + def test_const_detection_regression(self): + # regression test 707 + from qupulse.pulses import PointPT + second_point_pt = PointPT([(0, 'v_0+v_1'), + ('t_2', 'v_0', 'linear')], + channel_names=('A',), + measurements=[('M', 0, 1)]) + parameters = dict(t=3, + t_2=2, + v_0=1, + v_1=1.4) + channel_mapping = {'A': 'A'} + wf = second_point_pt.build_waveform(parameters=parameters, channel_mapping=channel_mapping) + self.assertIsInstance(wf, TableWaveform) + def test_validate_input_duplicate_removal(self): validated = TableWaveform._validate_input([TableWaveformEntry(0.0, 0.2, HoldInterpolationStrategy()), TableWaveformEntry(0.1, 0.2, LinearInterpolationStrategy()), From 578cee9e14db6ff6c95f367a6f6b9733dd49e568 Mon Sep 17 00:00:00 2001 From: Simon Humpohl Date: Thu, 1 Dec 2022 15:35:26 +0100 Subject: [PATCH 2/3] Fix wrong interpolation in const detection --- qupulse/_program/waveforms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qupulse/_program/waveforms.py b/qupulse/_program/waveforms.py index e9ce8f6f0..a173f3bf3 100644 --- a/qupulse/_program/waveforms.py +++ b/qupulse/_program/waveforms.py @@ -298,7 +298,7 @@ def _validate_input(input_waveform_table: Sequence[EntryInInit]) -> Union[Tuple[ raise ValueError('Negative time values are not allowed.') # constant_v is None <=> the waveform is constant until up to the current entry - constant_v = first_interp.constant_value((previous_t, previous_v), (t, v)) + constant_v = interp.constant_value((previous_t, previous_v), (t, v)) for next_t, next_v, next_interp in input_iter: if next_t < t: From e117c3a1e612a4206aa2e75ae786d44150b4a6a6 Mon Sep 17 00:00:00 2001 From: Simon Humpohl Date: Thu, 1 Dec 2022 15:37:21 +0100 Subject: [PATCH 3/3] Add newspiece --- changes.d/707.fix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes.d/707.fix diff --git a/changes.d/707.fix b/changes.d/707.fix new file mode 100644 index 000000000..33e9e9f8e --- /dev/null +++ b/changes.d/707.fix @@ -0,0 +1 @@ +Fixed that single segment tables where always interpreted to be constant.