You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
deftest_3():
a, b=cirq.LineQubit.range(2)
c=cirq.Circuit(cirq.Moment(cirq.X(a)))
print(c)
c.insert(1, cirq.Y.on_each(b, a), strategy=cirq.InsertStrategy.INLINE)
print(c)
# 0: ───X───# 0: ───X───Y───# 1: ───Y─────── # Seems like both Y's should go on moment[1], or maybe both to moment[0] (if you've read the docs about INLINE going to moment[i-1]), but this result puts them in two different moments, which is the least intuitive option.
deftest_4():
a, b=cirq.LineQubit.range(2)
c=cirq.Circuit(cirq.Moment(cirq.X(a)))
print(c)
c.insert(1, cirq.Y.on_each(a, b), strategy=cirq.InsertStrategy.INLINE) # opposite order from test_3print(c)
# 0: ───X───# 0: ───X───Y───# 1: ───────Y─── # Matches intuition, but inconsistent with test_3
deftest_5():
a, b=cirq.LineQubit.range(2)
c=cirq.Circuit(cirq.Moment(cirq.X(a)))
print(c)
c.insert(0, cirq.Y.on_each(b, a), strategy=cirq.InsertStrategy.EARLIEST)
print(c)
# 0: ───X───# 0: ───X───Y─── # Insert to moment[0] ends up in moment[1] # 1: ───Y───────
deftest_6():
a, b=cirq.LineQubit.range(2)
c=cirq.Circuit(cirq.Moment(cirq.X(a)))
print(c)
c.insert(0, cirq.Y.on_each(a, b), strategy=cirq.InsertStrategy.EARLIEST) # opposite order from test_5print(c)
# 0: ───X───# 0: ───Y───X─── # Matches intuition, but inconsistent with test_5# 1: ───Y───────
deftest_7():
q=cirq.LineQubit(0)
c=cirq.Circuit(cirq.Moment(), cirq.Moment(), cirq.Moment(cirq.Z(q)))
print(c)
c.insert(1, cirq.Y(q), strategy=cirq.InsertStrategy.INLINE)
print(c)
# 0: ───────────Z───# 0: ───Y───────Z─── # This is the documented behavior but I think not what most users would expect
These would all be "fixed" by the commit in the comment linked above, which looks ahead for ops that would create new moments, and creates them preemptively instead of op-by-op. But it would break anything that was for some reason dependent on this behavior. I didn't notice any cases of that in existing code, other than two test cases in circuit_test equivalent to test_7 and test_3 above.
The text was updated successfully, but these errors were encountered:
I noticed a few oddities when investigating #6711 (comment). Documenting these here.
These would all be "fixed" by the commit in the comment linked above, which looks ahead for ops that would create new moments, and creates them preemptively instead of op-by-op. But it would break anything that was for some reason dependent on this behavior. I didn't notice any cases of that in existing code, other than two test cases in circuit_test equivalent to test_7 and test_3 above.
The text was updated successfully, but these errors were encountered: