Skip to content

Commit 3576529

Browse files
committed
Add comment explaining what's happening
1 parent a82b6ec commit 3576529

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

qsimcirq_tests/qsimcirq_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,16 @@ def __init__(self, *args, **kwargs):
10571057
super().__init__(*args, **kwargs)
10581058

10591059
def _mixture_(self):
1060+
# Cirq's mixture() function in mixture_protocol.py returns tuples of
1061+
# the form (probability, unitary peration). It does this by applying
1062+
# Cirq's unitary() function to the second elements of the tuples
1063+
# returned from here. Now, the values in self._prob_op_pairs will be
1064+
# tuples of the form (probability, NoiseStep). NoiseStep defines a
1065+
# _unitary_() method that simply returns the array as-is. Thus, when
1066+
# Cirq's mixture() function gets the value returned here and calls
1067+
# unitary() on those NoiseStep objects, the values unitary() returns
1068+
# will not actually be unitary. This is done knowingly. The nonunitary
1069+
# values are eventually normalized in test_multi_qubit_noise().
10601070
return [(prob, op) for prob, op, in self._prob_op_pairs]
10611071

10621072

0 commit comments

Comments
 (0)