Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 = [gate for gate in _BASIS_1Q if gate not in {"v", "w", "id", "iden", "sinv"}]
gates_2q= list(_BASIS_2Q.keys())

if gates == "all":
if num_qubits == 1:
Expand Down
25 changes: 25 additions & 0 deletions test/python/quantum_info/operators/symplectic/test_clifford.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

"""Tests for Clifford class."""

import os
import subprocess
import sys
import textwrap
import unittest
import itertools
import numpy as np
Expand Down Expand Up @@ -174,6 +178,27 @@ def test_append_1_qubit_gate(self):
np.all(np.array(value_destabilizer == [target_destabilizer[gate_name]]))
)

@combine(hash_seed=["1","2","10","100"])
def test_random_clifford_circuit_with_same_seed(self, hash_seed):
env = os.environ.copy()
env["PYTHONHASHSEED"] = hash_seed

test_script= textwrap.dedent("""
from qiskit.circuit.random.utils import random_clifford_circuit
cliff_circuit = random_clifford_circuit(num_qubits=10, num_gates=100, gates="all", seed=0)
print(cliff_circuit.count_ops())
""")

result = subprocess.run(
[sys.executable, "-c", test_script],
env=env,
capture_output=True,
text=True,
check=True
)

self.assertEqual(result.stdout, "OrderedDict({'sxdg': 10, 'sdg': 10, 'iswap': 9, 'cz': 9, 'id': 9, 'h': 8, 'cy': 8, 'x': 6, 'ecr': 6, 'cx': 6, 'dcx': 4, 'swap': 4, 's': 4, 'y': 3, 'sx': 3, 'z': 1})\n")

@combine(
gate=[
IGate(),
Expand Down