-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delay.__eq__
does not compare the delay unit
#13812
Comments
Thanks Will. For the immediate period, I've left the non-equality of 1000ms and 1s in place, since it's not clear to me whether a user might expect those to compare equal (why would they have specified them with different units?) and it's faffier to make work in the current Rust structure, but #13816 will fix your s/dt comparisons. |
Thanks, @jakelishman! Do you happen to know what happens with the circuit case now? My guess was that delay gets turned into a Rust instruction object that does consider the unit, but I didn't trace it down enough to tell. Does #13816 align the Python class comparison with the circuit one? |
When we bring the |
And yeah, #13816 makes the two behaviours match, but they're not calling the same code (which would be a mess to do from Python, and wildly expensive from Rust), so it's just that the same logic is implemented twice. It's not pretty, but it's the same as happens with gates, and tbh, a lot of Qiskit's equality model is kind of messy at best, and broken at worst. Part of the reason I didn't do the unit-conversion comparisons for s/ms/etc is because it'd be ugly to achieve with both the current Rust and Python structures. |
Environment
What is happening?
When comparing two
Delay
instructions, only theduration
argument to__init__
matters, not theunit
argument.How can we reproduce the issue?
What should happen?
The code above should print False/False but it prints False/True.
Any suggestions?
Before #13486, both the circuit and instruction comparisons above were true. Now the circuit one is false. This came up in Qiskit Experiments because of this other bug with delay units and qpy. A test that ran a circuit with a delay roundtrip through qpy that used to pass even though the delay unit was lost started to fail.
The text was updated successfully, but these errors were encountered: