From 6e3d42e2043c301cfc73f248876ceb14c08e156d Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Thu, 6 May 2021 10:56:53 +0200 Subject: [PATCH 01/17] make waveform amplitude limit optional --- qiskit/pulse/library/waveform.py | 14 ++++++++++++-- test/python/pulse/test_pulse_lib.py | 9 +++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/qiskit/pulse/library/waveform.py b/qiskit/pulse/library/waveform.py index 1ce787d937ec..a271f628c7e0 100644 --- a/qiskit/pulse/library/waveform.py +++ b/qiskit/pulse/library/waveform.py @@ -26,10 +26,13 @@ class Waveform(Pulse): duration of the backend cycle-time, dt. """ + limit_amplitude = True + def __init__( self, samples: Union[np.ndarray, List[complex]], name: Optional[str] = None, + limit_amplitude: Optional[bool] = None, epsilon: float = 1e-7, ): """Create new sample pulse command. @@ -37,6 +40,7 @@ def __init__( Args: samples: Complex array of the samples in the pulse envelope. name: Unique name to identify the pulse. + limit_amplitude: If True, then limit the amplitude of the waveform to 1. epsilon: Pulse sample norm tolerance for clipping. If any sample's norm exceeds unity by less than or equal to epsilon it will be clipped to unit norm. If the sample @@ -44,6 +48,8 @@ def __init__( """ samples = np.asarray(samples, dtype=np.complex_) + if limit_amplitude is not None: + self.limit_amplitude = limit_amplitude self.epsilon = epsilon self._samples = self._clip(samples, epsilon=epsilon) super().__init__(duration=len(samples), name=name) @@ -95,8 +101,12 @@ def _clip(self, samples: np.ndarray, epsilon: float = 1e-7) -> np.ndarray: samples[clip_where] = clipped_samples samples_norm[clip_where] = np.abs(clipped_samples) - if np.any(samples_norm > 1.0): - raise PulseError("Pulse contains sample with norm greater than 1+epsilon.") + if np.any(samples_norm > 1.0) and self.limit_amplitude: + amp = np.max(samples_norm) + raise PulseError( + f"Pulse contains sample with norm {amp} greater than 1+epsilon." + " This can be overruled by setting Waveform.limit_amplitude." + ) return samples diff --git a/test/python/pulse/test_pulse_lib.py b/test/python/pulse/test_pulse_lib.py index 2e5c9708aeca..75e2644914e5 100644 --- a/test/python/pulse/test_pulse_lib.py +++ b/test/python/pulse/test_pulse_lib.py @@ -79,6 +79,15 @@ def test_pulse_limits(self): with self.assertRaises(PulseError): Waveform(invalid_const * np.exp(1j * 2 * np.pi * np.linspace(0, 1, 1000))) + invalid_const = 1.1 + Waveform.limit_amplitude = False + wave = Waveform(invalid_const*np.exp(1j*2*np.pi*np.linspace(0, 1, 1000))) + self.assertGreater(np.max(np.abs(wave.samples)), 1.0) + with self.assertRaises(PulseError): + wave = Waveform(invalid_const*np.exp(1j*2*np.pi * + np.linspace(0, 1, 1000)), limit_amplitude=True) + Waveform.limit_amplitude = True + # Test case where data is converted to python types with complex as a list # with form [re, im] and back to a numpy array. # This is how the transport layer handles samples in the qobj so it is important From 930e36aa94a9f7ee64a3697ee5555e61808f0bdb Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Thu, 6 May 2021 14:08:17 +0200 Subject: [PATCH 02/17] change order of Waveform arguments for backwards compatibility --- qiskit/pulse/library/waveform.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qiskit/pulse/library/waveform.py b/qiskit/pulse/library/waveform.py index a271f628c7e0..05c3d73bb70b 100644 --- a/qiskit/pulse/library/waveform.py +++ b/qiskit/pulse/library/waveform.py @@ -32,19 +32,19 @@ def __init__( self, samples: Union[np.ndarray, List[complex]], name: Optional[str] = None, - limit_amplitude: Optional[bool] = None, epsilon: float = 1e-7, + limit_amplitude: Optional[bool] = None, ): """Create new sample pulse command. Args: samples: Complex array of the samples in the pulse envelope. name: Unique name to identify the pulse. - limit_amplitude: If True, then limit the amplitude of the waveform to 1. epsilon: Pulse sample norm tolerance for clipping. If any sample's norm exceeds unity by less than or equal to epsilon it will be clipped to unit norm. If the sample norm is greater than 1+epsilon an error will be raised. + limit_amplitude: If True, then limit the amplitude of the waveform to 1. """ samples = np.asarray(samples, dtype=np.complex_) From d98f165321538ec88118e1001cb6fc4fc113c5a9 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Thu, 6 May 2021 15:03:21 +0200 Subject: [PATCH 03/17] update black once more --- test/python/pulse/test_pulse_lib.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/python/pulse/test_pulse_lib.py b/test/python/pulse/test_pulse_lib.py index 75e2644914e5..3cd0e3ff0c16 100644 --- a/test/python/pulse/test_pulse_lib.py +++ b/test/python/pulse/test_pulse_lib.py @@ -81,11 +81,13 @@ def test_pulse_limits(self): invalid_const = 1.1 Waveform.limit_amplitude = False - wave = Waveform(invalid_const*np.exp(1j*2*np.pi*np.linspace(0, 1, 1000))) + wave = Waveform(invalid_const * np.exp(1j * 2 * np.pi * np.linspace(0, 1, 1000))) self.assertGreater(np.max(np.abs(wave.samples)), 1.0) with self.assertRaises(PulseError): - wave = Waveform(invalid_const*np.exp(1j*2*np.pi * - np.linspace(0, 1, 1000)), limit_amplitude=True) + wave = Waveform( + invalid_const * np.exp(1j * 2 * np.pi * np.linspace(0, 1, 1000)), + limit_amplitude=True, + ) Waveform.limit_amplitude = True # Test case where data is converted to python types with complex as a list From eb4760f97519c01c56fcb42d0fb2b085b8b1d098 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Sun, 16 May 2021 20:19:26 +0200 Subject: [PATCH 04/17] Update qiskit/pulse/library/waveform.py Co-authored-by: Thomas Alexander --- qiskit/pulse/library/waveform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit/pulse/library/waveform.py b/qiskit/pulse/library/waveform.py index 05c3d73bb70b..b5ae3b4d3242 100644 --- a/qiskit/pulse/library/waveform.py +++ b/qiskit/pulse/library/waveform.py @@ -44,7 +44,7 @@ def __init__( If any sample's norm exceeds unity by less than or equal to epsilon it will be clipped to unit norm. If the sample norm is greater than 1+epsilon an error will be raised. - limit_amplitude: If True, then limit the amplitude of the waveform to 1. + limit_amplitude: If ``True``, then limit the amplitude of the waveform to 1. The default value of ``None`` causes the flag value to be derived from :py:attr:`~limit_amplitude` which is ``True`` by default but may be set by the user to disable amplitude checks globally. """ samples = np.asarray(samples, dtype=np.complex_) From 68ec52994a263544e1f40ff9a10a99b35002d602 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Tue, 18 May 2021 09:50:35 +0200 Subject: [PATCH 05/17] move limit_amplitude from waveform to pulse --- qiskit/pulse/library/pulse.py | 18 +++++++++++++++++- qiskit/pulse/library/waveform.py | 6 ------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/qiskit/pulse/library/pulse.py b/qiskit/pulse/library/pulse.py index 4dd1b733f025..0eabc155d0ff 100644 --- a/qiskit/pulse/library/pulse.py +++ b/qiskit/pulse/library/pulse.py @@ -26,10 +26,26 @@ class Pulse(ABC): modulation phase and frequency are specified separately from ``Pulse``s. """ + limit_amplitude = True + @abstractmethod - def __init__(self, duration: Union[int, ParameterExpression], name: Optional[str] = None): + def __init__( + self, + duration: Union[int, ParameterExpression], + name: Optional[str] = None, + limit_amplitude: Optional[bool] = True, + ): + """ + Args: + duration: Duration of the pulse + name: Optional name for the pulse + limit_amplitude: If ``True``, then limit the amplitude of the waveform to 1. The default value of ``None`` causes the flag value to be derived from :py:attr:`~limit_amplitude` which is ``True`` by default but may be set by the user to disable amplitude checks globally. + """ + self.duration = duration self.name = name + if limit_amplitude is not None: + self.limit_amplitude = limit_amplitude @property def id(self) -> int: # pylint: disable=invalid-name diff --git a/qiskit/pulse/library/waveform.py b/qiskit/pulse/library/waveform.py index b5ae3b4d3242..6562f940c2e6 100644 --- a/qiskit/pulse/library/waveform.py +++ b/qiskit/pulse/library/waveform.py @@ -26,14 +26,11 @@ class Waveform(Pulse): duration of the backend cycle-time, dt. """ - limit_amplitude = True - def __init__( self, samples: Union[np.ndarray, List[complex]], name: Optional[str] = None, epsilon: float = 1e-7, - limit_amplitude: Optional[bool] = None, ): """Create new sample pulse command. @@ -44,12 +41,9 @@ def __init__( If any sample's norm exceeds unity by less than or equal to epsilon it will be clipped to unit norm. If the sample norm is greater than 1+epsilon an error will be raised. - limit_amplitude: If ``True``, then limit the amplitude of the waveform to 1. The default value of ``None`` causes the flag value to be derived from :py:attr:`~limit_amplitude` which is ``True`` by default but may be set by the user to disable amplitude checks globally. """ samples = np.asarray(samples, dtype=np.complex_) - if limit_amplitude is not None: - self.limit_amplitude = limit_amplitude self.epsilon = epsilon self._samples = self._clip(samples, epsilon=epsilon) super().__init__(duration=len(samples), name=name) From fe16b2ba498437ade099021e3c8e775dbf299392 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Tue, 18 May 2021 10:14:27 +0200 Subject: [PATCH 06/17] use limit_amplitude in pulses; add tests --- qiskit/pulse/library/parametric_pulses.py | 24 +++++++++++++++++------ qiskit/pulse/library/pulse.py | 4 ++-- qiskit/pulse/library/waveform.py | 6 ++++-- test/python/pulse/test_pulse_lib.py | 9 +++++++++ 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/qiskit/pulse/library/parametric_pulses.py b/qiskit/pulse/library/parametric_pulses.py index 898b0ee28e08..1f309742d270 100644 --- a/qiskit/pulse/library/parametric_pulses.py +++ b/qiskit/pulse/library/parametric_pulses.py @@ -171,8 +171,12 @@ def get_waveform(self) -> Waveform: return gaussian(duration=self.duration, amp=self.amp, sigma=self.sigma, zero_ends=True) def validate_parameters(self) -> None: - if not _is_parameterized(self.amp) and abs(self.amp) > 1.0: - raise PulseError("The amplitude norm must be <= 1, " "found: {}".format(abs(self.amp))) + if not _is_parameterized(self.amp) and abs(self.amp) > 1.0 and self.limit_amplitude: + raise PulseError( + "The amplitude norm must be <= 1, " + "found: {}".format(abs(self.amp)) + + "This can be overruled by setting Pulse.limit_amplitude." + ) if not _is_parameterized(self.sigma) and self.sigma <= 0: raise PulseError("Sigma must be greater than 0.") @@ -256,8 +260,12 @@ def get_waveform(self) -> Waveform: ) def validate_parameters(self) -> None: - if not _is_parameterized(self.amp) and abs(self.amp) > 1.0: - raise PulseError("The amplitude norm must be <= 1, " "found: {}".format(abs(self.amp))) + if not _is_parameterized(self.amp) and abs(self.amp) > 1.0 and self.limit_amplitude: + raise PulseError( + "The amplitude norm must be <= 1, " + "found: {}".format(abs(self.amp)) + + "This can be overruled by setting Pulse.limit_amplitude." + ) if not _is_parameterized(self.sigma) and self.sigma <= 0: raise PulseError("Sigma must be greater than 0.") if not _is_parameterized(self.width) and (self.width < 0 or self.width >= self.duration): @@ -453,8 +461,12 @@ def get_waveform(self) -> Waveform: return constant(duration=self.duration, amp=self.amp) def validate_parameters(self) -> None: - if not _is_parameterized(self.amp) and abs(self.amp) > 1.0: - raise PulseError("The amplitude norm must be <= 1, " "found: {}".format(abs(self.amp))) + if not _is_parameterized(self.amp) and abs(self.amp) > 1.0 and self.limit_amplitude: + raise PulseError( + "The amplitude norm must be <= 1, " + "found: {}".format(abs(self.amp)) + + "This can be overruled by setting Pulse.limit_amplitude." + ) @property def parameters(self) -> Dict[str, Any]: diff --git a/qiskit/pulse/library/pulse.py b/qiskit/pulse/library/pulse.py index 0eabc155d0ff..58d983f57224 100644 --- a/qiskit/pulse/library/pulse.py +++ b/qiskit/pulse/library/pulse.py @@ -33,9 +33,9 @@ def __init__( self, duration: Union[int, ParameterExpression], name: Optional[str] = None, - limit_amplitude: Optional[bool] = True, + limit_amplitude: Optional[bool] = None, ): - """ + """Abstract base class for pulses Args: duration: Duration of the pulse name: Optional name for the pulse diff --git a/qiskit/pulse/library/waveform.py b/qiskit/pulse/library/waveform.py index 6562f940c2e6..68667b45d531 100644 --- a/qiskit/pulse/library/waveform.py +++ b/qiskit/pulse/library/waveform.py @@ -31,6 +31,7 @@ def __init__( samples: Union[np.ndarray, List[complex]], name: Optional[str] = None, epsilon: float = 1e-7, + limit_amplitude: Optional[bool] = None, ): """Create new sample pulse command. @@ -41,12 +42,13 @@ def __init__( If any sample's norm exceeds unity by less than or equal to epsilon it will be clipped to unit norm. If the sample norm is greater than 1+epsilon an error will be raised. + limit_amplitude: Passed to parent Pulse """ + super().__init__(duration=len(samples), name=name, limit_amplitude=limit_amplitude) samples = np.asarray(samples, dtype=np.complex_) self.epsilon = epsilon self._samples = self._clip(samples, epsilon=epsilon) - super().__init__(duration=len(samples), name=name) @property def samples(self) -> np.ndarray: @@ -99,7 +101,7 @@ def _clip(self, samples: np.ndarray, epsilon: float = 1e-7) -> np.ndarray: amp = np.max(samples_norm) raise PulseError( f"Pulse contains sample with norm {amp} greater than 1+epsilon." - " This can be overruled by setting Waveform.limit_amplitude." + " This can be overruled by setting Pulse.limit_amplitude." ) return samples diff --git a/test/python/pulse/test_pulse_lib.py b/test/python/pulse/test_pulse_lib.py index 3cd0e3ff0c16..07c64651132c 100644 --- a/test/python/pulse/test_pulse_lib.py +++ b/test/python/pulse/test_pulse_lib.py @@ -13,8 +13,10 @@ """Unit tests for pulse waveforms.""" import unittest +from unittest.mock import patch import numpy as np +import qiskit from qiskit.pulse.library import ( Waveform, Constant, @@ -202,6 +204,13 @@ def test_constant_samples(self): self.assertEqual(const.get_waveform().samples[0], 0.1 + 0.4j) self.assertEqual(len(const.get_waveform().samples), 150) + with self.assertRaises(PulseError): + const = Constant(duration=150, amp=1.1 + 0.4j) + + with patch("qiskit.pulse.library.parametric_pulses.Pulse.limit_amplitude", new=False): + const = qiskit.pulse.library.parametric_pulses.Constant(duration=150, amp=0.1 + 0.4j) + print(const.limit_amplitude) + def test_parameters(self): """Test that the parameters can be extracted as a dict through the `parameters` attribute.""" From 85ddd0518ad1b3fb3893280304ad1b0aea7e61ff Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Tue, 18 May 2021 10:16:54 +0200 Subject: [PATCH 07/17] format strings --- qiskit/pulse/library/parametric_pulses.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/qiskit/pulse/library/parametric_pulses.py b/qiskit/pulse/library/parametric_pulses.py index 1f309742d270..9a85923773c0 100644 --- a/qiskit/pulse/library/parametric_pulses.py +++ b/qiskit/pulse/library/parametric_pulses.py @@ -173,8 +173,7 @@ def get_waveform(self) -> Waveform: def validate_parameters(self) -> None: if not _is_parameterized(self.amp) and abs(self.amp) > 1.0 and self.limit_amplitude: raise PulseError( - "The amplitude norm must be <= 1, " - "found: {}".format(abs(self.amp)) + f"The amplitude norm must be <= 1, found: {abs(self.amp)}" + "This can be overruled by setting Pulse.limit_amplitude." ) if not _is_parameterized(self.sigma) and self.sigma <= 0: @@ -262,8 +261,7 @@ def get_waveform(self) -> Waveform: def validate_parameters(self) -> None: if not _is_parameterized(self.amp) and abs(self.amp) > 1.0 and self.limit_amplitude: raise PulseError( - "The amplitude norm must be <= 1, " - "found: {}".format(abs(self.amp)) + f"The amplitude norm must be <= 1, found: {abs(self.amp)}" + "This can be overruled by setting Pulse.limit_amplitude." ) if not _is_parameterized(self.sigma) and self.sigma <= 0: @@ -371,8 +369,11 @@ def get_waveform(self) -> Waveform: ) def validate_parameters(self) -> None: - if not _is_parameterized(self.amp) and abs(self.amp) > 1.0: - raise PulseError("The amplitude norm must be <= 1, " "found: {}".format(abs(self.amp))) + if not _is_parameterized(self.amp) and abs(self.amp) > 1.0 and self.limit_amplitude: + raise PulseError( + f"The amplitude norm must be <= 1, found: {abs(self.amp)}" + + "This can be overruled by setting Pulse.limit_amplitude." + ) if not _is_parameterized(self.sigma) and self.sigma <= 0: raise PulseError("Sigma must be greater than 0.") if not _is_parameterized(self.beta) and isinstance(self.beta, complex): @@ -463,8 +464,7 @@ def get_waveform(self) -> Waveform: def validate_parameters(self) -> None: if not _is_parameterized(self.amp) and abs(self.amp) > 1.0 and self.limit_amplitude: raise PulseError( - "The amplitude norm must be <= 1, " - "found: {}".format(abs(self.amp)) + f"The amplitude norm must be <= 1, found: {abs(self.amp)}" + "This can be overruled by setting Pulse.limit_amplitude." ) From 7306f2b1755afc25db9fd2b5b4e0e21de2d8c37a Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Tue, 18 May 2021 12:03:29 +0200 Subject: [PATCH 08/17] fix max line length --- qiskit/pulse/library/pulse.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qiskit/pulse/library/pulse.py b/qiskit/pulse/library/pulse.py index 58d983f57224..503c8bb411ca 100644 --- a/qiskit/pulse/library/pulse.py +++ b/qiskit/pulse/library/pulse.py @@ -39,7 +39,10 @@ def __init__( Args: duration: Duration of the pulse name: Optional name for the pulse - limit_amplitude: If ``True``, then limit the amplitude of the waveform to 1. The default value of ``None`` causes the flag value to be derived from :py:attr:`~limit_amplitude` which is ``True`` by default but may be set by the user to disable amplitude checks globally. + limit_amplitude: If ``True``, then limit the amplitude of the waveform to 1. The default value + of ``None`` causes the flag value to be derived from :py:attr:`~limit_amplitude` + which is ``True`` by default but may be set by the user to disable + amplitude checks globally. """ self.duration = duration From 970040c0a30b47b649acff79361c058a40cfbe5a Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Tue, 18 May 2021 12:58:46 +0200 Subject: [PATCH 09/17] fix line length --- qiskit/pulse/library/pulse.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/qiskit/pulse/library/pulse.py b/qiskit/pulse/library/pulse.py index 503c8bb411ca..4cb28da53911 100644 --- a/qiskit/pulse/library/pulse.py +++ b/qiskit/pulse/library/pulse.py @@ -39,10 +39,11 @@ def __init__( Args: duration: Duration of the pulse name: Optional name for the pulse - limit_amplitude: If ``True``, then limit the amplitude of the waveform to 1. The default value - of ``None`` causes the flag value to be derived from :py:attr:`~limit_amplitude` - which is ``True`` by default but may be set by the user to disable - amplitude checks globally. + limit_amplitude: If ``True``, then limit the amplitude of the waveform to 1. + The default value of ``None`` causes the flag value to be + derived from :py:attr:`~limit_amplitude` which is ``True`` + by default but may be set by the user to disable amplitude + checks globally. """ self.duration = duration From 2551f7afe3f0682550067c7393b893b2200578ba Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Fri, 21 May 2021 10:37:06 +0200 Subject: [PATCH 10/17] add release notes --- ...form-amplitude-limit-c58e2ec61f6789e6.yaml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml diff --git a/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml b/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml new file mode 100644 index 000000000000..d6477aea6e84 --- /dev/null +++ b/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml @@ -0,0 +1,24 @@ +--- +prelude: > + The Qiskit Waveform class does not allow amplitudes larger than 1. This is + enforced several subclasses such as Gaussian and Constant. + An option `limit_amplitude` is added to the Pulse class that allows + disabling the limit on the amplitude. +features: + - | + Add option to the Pulse class to enable or disable the limit of 1 on the waveform amplitude. + Fixes #6012 +issues: + - | +upgrade: + - | +deprecations: + - | +critical: + - | +security: + - | +fixes: + - | +other: + - | From e4dcc5736806b6e264bb4e928cbaf3bd613af361 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Sun, 23 May 2021 00:41:43 +0200 Subject: [PATCH 11/17] fix reno file --- ...form-amplitude-limit-c58e2ec61f6789e6.yaml | 25 +++---------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml b/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml index d6477aea6e84..937b2778ff58 100644 --- a/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml +++ b/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml @@ -1,24 +1,7 @@ --- -prelude: > - The Qiskit Waveform class does not allow amplitudes larger than 1. This is - enforced several subclasses such as Gaussian and Constant. - An option `limit_amplitude` is added to the Pulse class that allows - disabling the limit on the amplitude. features: - | - Add option to the Pulse class to enable or disable the limit of 1 on the waveform amplitude. - Fixes #6012 -issues: - - | -upgrade: - - | -deprecations: - - | -critical: - - | -security: - - | -fixes: - - | -other: - - | + Adds global option `limit_amplitude` to the Pulse class to enable or disable the limit of 1 on the waveform + amplitude. Fixes #6012. + With the option enabked, the `Waveform` class does not allow amplitudes larger than 1. This is + enforced several subclasses such as `Gaussian` and `Constant`. From f0fedc74b5b72c5492b534cbf68593be8f0d127f Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Mon, 24 May 2021 20:30:18 +0200 Subject: [PATCH 12/17] Update releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml Co-authored-by: Thomas Alexander --- ...on-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml b/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml index 937b2778ff58..58f1e4e7647d 100644 --- a/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml +++ b/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml @@ -3,5 +3,5 @@ features: - | Adds global option `limit_amplitude` to the Pulse class to enable or disable the limit of 1 on the waveform amplitude. Fixes #6012. - With the option enabked, the `Waveform` class does not allow amplitudes larger than 1. This is + With the option enabled, the `Waveform` class does not allow amplitudes larger than 1. This is enforced several subclasses such as `Gaussian` and `Constant`. From 8eb4ab61b3c7e558743feb1ab507f2e39eaedbf0 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Mon, 24 May 2021 20:30:28 +0200 Subject: [PATCH 13/17] Update releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml Co-authored-by: Thomas Alexander --- ...on-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml b/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml index 58f1e4e7647d..d91a67fcc1eb 100644 --- a/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml +++ b/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml @@ -4,4 +4,4 @@ features: Adds global option `limit_amplitude` to the Pulse class to enable or disable the limit of 1 on the waveform amplitude. Fixes #6012. With the option enabled, the `Waveform` class does not allow amplitudes larger than 1. This is - enforced several subclasses such as `Gaussian` and `Constant`. + enforced in several subclasses such as `Gaussian` and `Constant`. From 1981f60f849d77a6a29ae01d977d2479d7d19bf3 Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Mon, 24 May 2021 20:30:36 +0200 Subject: [PATCH 14/17] Update releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml Co-authored-by: Thomas Alexander --- ...on-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml b/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml index d91a67fcc1eb..e58243de9a33 100644 --- a/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml +++ b/releasenotes/notes/add-option-to-disable-waveform-amplitude-limit-c58e2ec61f6789e6.yaml @@ -1,7 +1,7 @@ --- features: - | - Adds global option `limit_amplitude` to the Pulse class to enable or disable the limit of 1 on the waveform + Adds a global option `limit_amplitude` to the Pulse class to enable or disable the limit of 1. on the waveform amplitude. Fixes #6012. With the option enabled, the `Waveform` class does not allow amplitudes larger than 1. This is enforced in several subclasses such as `Gaussian` and `Constant`. From 182a91b2f897e4f8216a109f6ceccac6f9dc0d9f Mon Sep 17 00:00:00 2001 From: Thomas Alexander Date: Wed, 9 Jun 2021 10:31:06 -0300 Subject: [PATCH 15/17] Remove unnecessary print statement. --- test/python/pulse/test_pulse_lib.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/python/pulse/test_pulse_lib.py b/test/python/pulse/test_pulse_lib.py index 07c64651132c..abddd76a3f9d 100644 --- a/test/python/pulse/test_pulse_lib.py +++ b/test/python/pulse/test_pulse_lib.py @@ -209,7 +209,6 @@ def test_constant_samples(self): with patch("qiskit.pulse.library.parametric_pulses.Pulse.limit_amplitude", new=False): const = qiskit.pulse.library.parametric_pulses.Constant(duration=150, amp=0.1 + 0.4j) - print(const.limit_amplitude) def test_parameters(self): """Test that the parameters can be extracted as a dict through the `parameters` From 763c40fbe30d52dc44fc4227e389592ed1fff27f Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Thu, 10 Jun 2021 09:45:27 +0200 Subject: [PATCH 16/17] trigger build, see #6539 From 60817f67236cb50725a0726656cb53c25f1bf5ec Mon Sep 17 00:00:00 2001 From: Pieter Eendebak Date: Thu, 10 Jun 2021 11:34:59 +0200 Subject: [PATCH 17/17] trigger build