Closed paba92 closed 2 weeks ago
QobjEvo.tlist
was removed and qutip-qip
code was updated to match the change, but it seems qutip-qip
's documentation is out of sync...
Thanks @paba92 for the issue. Yes it is outdated. the correct script is
import numpy as np
from qutip import sigmaz, sigmay
from qutip_qip.device import Processor
from qutip_qip.noise import RandomNoise
# add control Hamiltonians
processor = Processor(1)
processor.add_control(sigmaz(), targets=0, label="sz")
# define pulse coefficients and tlist for all pulses
processor.set_coeffs({"sz": np.array([0.3, 0.5, 0. ])})
processor.set_tlist(np.array([0., np.pi/2., 2*np.pi/2, 3*np.pi/2]))
# define noise, loc and scale are keyword arguments for np.random.normal
gaussnoise = RandomNoise(
dt=0.01, rand_gen=np.random.normal, loc=0.00, scale=0.02)
processor.add_noise(gaussnoise)
# Plot the ideal pulse
fig1, axis1 = processor.plot_pulses(
title="Original control amplitude", figsize=(5,3),
use_control_latex=False)
# Plot the noisy pulse
qobjevo, _ = processor.get_qobjevo(noisy=True)
fig2, axis2 = processor.plot_pulses(
title="Noisy control amplitude", figsize=(5,3),
use_control_latex=False)
tlist = np.linspace(0., processor.get_full_tlist()[-1], 300)
noisy_coeff = [qobjevo(t)[0, 0] for t in tlist]
axis2[0].step(tlist, noisy_coeff)
Will make a fix soon.
Bug Description
Generating an QobjEvo object has no attribute tlist. This results in an error for the example code here. A minimal example for reproducing this error is provided.
Code to Reproduce the Bug
Code Output
Expected Behaviour
[0.0, 0.1, 0.3, 0.4]
Your Environment
Additional Context
No response