cirq.testing.random_circuit¶
-
cirq.testing.random_circuit(qubits: Union[Sequence[cirq.ops.raw_types.QubitId], int], n_moments: int, op_density: float, gate_domain: Optional[Dict[cirq.ops.raw_types.Gate, int]] = None) → cirq.circuits.circuit.Circuit[source]¶ Generates a random circuit.
Parameters: - qubits – the qubits that the circuit acts on. Because the qubits on which an operation acts are chosen randomly, not all given qubits may be acted upon.
- n_moments – the number of moments in the generated circuit.
- op_density – the expected proportion of qubits that are acted on in any moment.
- gate_domain – The set of gates to choose from, with a specified arity.
Raises: ValueError– * op_density is not in (0, 1). * gate_domain is empty. * qubits is an int less than 1 or an empty sequence.Returns: The randomly generated Circuit.