qiskit-community / qiskit-dynamics

Tools for building and solving models of quantum systems in Qiskit
https://qiskit-community.github.io/qiskit-dynamics/
Apache License 2.0
106 stars 60 forks source link

`add_sample` doesn't perform correctly for padding #111

Closed brosand closed 2 years ago

brosand commented 2 years ago

the add_sample function needs to be fixed, and tests need to be added to confirm that the padding works.

The code:

discrete = DiscreteSignal(dt=0.5, samples=np.array([]), carrier_freq=3.0)

t_vals = np.array([0.1, .6, 1.1, 1.6])

discrete3.add_samples(1, [4.0, 3.2])

Expected behavior: discrete.envelope(t_vals) = array([0.0, 4. +0.j, 3.2+0.j, 0. +0.j])

Actual behavior: discrete.envelope(t_vals) = array([4. +0.j, 3.2+0.j, 0. +0.j, 0. +0.j])

DanPuzzuoli commented 2 years ago

A PR I'm working on will fix this issue. May have been good to do it as a separate small fix but just needed it to proceed with what I was doing. I've added an additional test caset o check for this, and have also added more complicated tests in test_pulse_to_signals which rely on this functionality.