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

Fix error in schedule -> signal conversion for schedules with barrier instructions #203

Closed DanPuzzuoli closed 1 year ago

DanPuzzuoli commented 1 year ago

Summary

Closes #202.

This fixes an error in the schedule -> signal converter when the schedule contained a barrier instruction.

Details and comments

As described in #202, in the loop over instructions to construct the signals, there is a line chan = inst.channel.name, which assumes that inst.channel exists. Barrier instructions do not have a channel attribute, hence the error. This PR modifies this line to conditionally set chan based on whether inst.channel exists, and adds a test validating the correct parsing of a schedule with a barrier. Note that I've also removed the phase and freq variables set at the same time as chan, as they were only used in one subsequent line.

For completeness, the important thing to note here is that nothing actually needs to be done to "support" barrier instructions: