Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions qiskit/circuit/random/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,8 +708,8 @@ def random_clifford_circuit(num_qubits, num_gates, gates="all", seed=None):
QuantumCircuit: constructed circuit
"""

gates_1q = list(set(_BASIS_1Q.keys()) - {"v", "w", "id", "iden", "sinv"})
gates_2q = list(_BASIS_2Q.keys())
gates_1q = sorted(set(_BASIS_1Q.keys()) - {"v", "w", "id", "iden", "sinv"})
gates_2q = sorted(_BASIS_2Q.keys())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorted is perhaps a bit unnecessarily heavy as a normalisation step; dict is already consistently ordered (including the dict_keys iterator), so the sort of gates_2q isn't needed, and the top line can be something along the lines of

ignore_1q = {"v", "w", "id", "iden", "sinv"}
gates_1q = [gate for gate in _BASIS_1Q if gate not in ignore_1q]

and avoid the extra $\lg n$. (Not that this would be performance critical, but still.)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated it to the snippet you mentioned, I was thinking it was straightforward to just sort it it to be consistent across any changes in the source dictionary as well.


if gates == "all":
if num_qubits == 1:
Expand Down
Loading