Skip to content

[Bug]: Copied programs reject bus references from the schema they were built with #14

Description

@fedonman

Bug Description

_validate_bus compares a BusRef's schema against the program's with is, but deepcopy, loads and with_waveforms all hand back a program holding a fresh copy of the BusSchema. Every ref built from the original schema is then rejected as foreign, so you cannot keep building on a program derived from another one. BusSchema defines no __eq__, so identity is currently the only comparison available; giving it structural equality and comparing with == would fix all three paths.

Minimal Reproducible Example

import copy
import qprogram as qp
from qprogram.buses import BusSchema

s = BusSchema.transmon()
p = qp.QProgram(schema=s)
p.measure(s.q[0].readout, "r", "w")
copy.deepcopy(p).measure(s.q[0].readout, "r", "w")

Expected Behavior

A copied, reloaded or waveform-bound program keeps accepting bus references from the same schema it was built with.

Actual Behavior

File "src/qprogram/qprogram.py", line 925, in _validate_bus
    raise ValidationError(msg)
qprogram.errors.ValidationError: BusRef 'q0/readout' (element='q', kind='readout') comes from a different BusSchema than the one attached to this QProgram. A program may use only one schema; use a plain string bus name if you need to reference a bus that lives outside the schema.

System Information

qprogram 0.1.0
python   3.14.3 | Linux-7.0.0-30-generic-x86_64-with-glibc2.43
vendors  none

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    busesTouches bus schemas and bus references

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions