qiskit/releasenotes/notes/0.22/remove-symbolic-pulse-subcl...

43 lines
1.6 KiB
YAML

---
features:
- |
Symbolic pulse subclasses :class:`.Gaussian`, :class:`.GaussianSquare`,
:class:`.Drag` and :class:`.Constant` have been upgraded to
instantiate :class:`SymbolicPulse` rather than the subclass itself.
All parametric pulse objects in pulse programs must be symbolic pulse instances,
because subclassing is no longer necessary. Note that :class:`SymbolicPulse` can
uniquely identify a particular envelope with the symbolic expression object
defined in :attr:`SymbolicPulse.envelope`.
upgrade:
- |
``isinstance`` check with pulse classes :class:`.Gaussian`, :class:`.GaussianSquare`,
:class:`.Drag` and :class:`.Constant` will be invalidated because
these pulse subclasses are no longer instantiated. They will still work in Terra 0.22,
but you should begin transitioning immediately.
Instead of using type information, :attr:`SymbolicPulse.pulse_type` should be used.
This is assumed to be a unique string identifier for pulse envelopes,
and we can use string equality to investigate the pulse types. For example,
.. code-block:: python
from qiskit.pulse.library import Gaussian
pulse = Gaussian(160, 0.1, 40)
if isinstance(pulse, Gaussian):
print("This is Gaussian pulse.")
This code should be upgraded to
.. code-block:: python
from qiskit.pulse.library import Gaussian
pulse = Gaussian(160, 0.1, 40)
if pulse.pulse_type == "Gaussian":
print("This is Gaussian pulse.")
With the same reason, the class attributes such as ``pulse.__class__.__name__``
should not be accessed to get pulse type information.