# Qiskit library.gaussian() does not accept parametric expression

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('θ')
drive_amps=np.linspace(0.0,0.75,50)

with pulse.build(backend, name='example') as program:
pulse.set_frequency(fq1,pulse.drive_channel(0))
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

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__(
self,
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!