I'm trying to build a gaussian pulse in qiskit where I keep the amplitude as a parameter but for the followig code

theta = Parameter('θ')

with pulse.build(backend, name='example') as program:
  dur = 100
  amp = theta
  sig = 20
  gaussian_pulse = library.gaussian(dur, amp, sig)
  pulse.play(gaussian_pulse, pulse.drive_channel(0))

I get an error that ParametricExpression cannot be cast as complex. From the documentation it seems that gaussian(duration, amp, sigma) takes the input (Union[complex, ParameterExpression]) for amp but I have not been able to get the input to work. Has anyone found a way around this?


1 Answer 1


Just change library.gaussian to become library.Gaussian with capital G.

Qiskit Pulse contains both qiskit.pulse.library.gaussian and qiskit.pulse.library.Gaussian

gaussian is a function with the signature:

def gaussian(
    duration: int, amp: complex, sigma: float, name: Optional[str] = None, zero_ends: bool = True
) -> Waveform

Note the type of amp parameter.

And Gaussian is a class whose constructor has the signature:

def __init__(
    duration: Union[int, ParameterExpression],
    amp: Union[complex, ParameterExpression],
    sigma: Union[float, ParameterExpression],
    name: Optional[str] = None,
    limit_amplitude: Optional[bool] = None,

Again, note the type of amp parameter.

As you want to create a parametric pulse, you need the Gaussian class not the gaussian function!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.