Skip to content

Commit c22bee0

Browse files
Review comments.
1 parent cf4e1d4 commit c22bee0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

qsimcirq/qsim_simulator.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,10 @@ def _sample_measure_results(
379379
for key, op in meas_ops.items():
380380
meas_indices = [qubit_map[qubit] for qubit in op.qubits]
381381
invert_mask = op.gate.full_invert_mask()
382-
# Match result order to order in ops, then apply invert mask
383-
permuted_results = full_results[:, meas_indices]
384-
results[key] = np.logical_xor(permuted_results, invert_mask)
382+
# Apply invert mask to re-ordered results
383+
results[key] = np.logical_xor(
384+
full_results[:, meas_indices], invert_mask
385+
)
385386

386387
else:
387388
options["c"] = self._translate_circuit(
@@ -399,11 +400,9 @@ def _sample_measure_results(
399400
options["s"] = self.get_seed()
400401
measurements[i] = sampler_fn(options)
401402

402-
for key, bound in bounds.items():
403+
for key, (start, end) in bounds.items():
403404
invert_mask = meas_ops[key].gate.full_invert_mask()
404-
permutation = list(range(bound[0], bound[1]))
405-
permuted_measurements = measurements[:, permutation]
406-
results[key] = np.logical_xor(permuted_measurements, invert_mask)
405+
results[key] = np.logical_xor(measurements[:, start:end], invert_mask)
407406

408407
return results
409408

0 commit comments

Comments
 (0)