Module: cirq.testing

Utilities for testing code.

Modules

asynchronous module

circuit_compare module

consistent_act_on module

consistent_decomposition module

consistent_pauli_expansion module

consistent_phase_by module

consistent_protocols module

consistent_qasm module

consistent_resolve_parameters module

consistent_specified_has_unitary module

deprecation module

equals_tester module: A utility class for testing equality methods.

equivalent_basis_map module

equivalent_repr_eval module

json module

lin_alg_utils module: A testing class with utilities for checking linear algebra.

logs module: Helper for testing python logging statements.

no_identifier_qubit module

order_tester module: A utility class for testing ordering methods.

sample_circuits module

Classes

class EqualsTester: Tests equality against user-provided disjoint equivalence groups.

class NoIdentifierQubit: A singleton qubit type that does not have a qudit variant.

class OrderTester: Tests ordering against user-provided disjoint ordered groups or items.

Functions

assert_all_implemented_act_on_effects_match_unitary(...): Uses val's effect on final_state_vector to check act_on(val)'s behavior.

assert_allclose_up_to_global_phase(...): Checks if a ~= b * exp(i t) for some t.

assert_circuits_with_terminal_measurements_are_equivalent(...): Determines if two circuits have equivalent effects.

assert_commutes_magic_method_consistent_with_unitaries(...)

assert_consistent_resolve_parameters(...)

assert_decompose_is_consistent_with_unitary(...): Uses val._unitary_ to check val._phase_by_'s behavior.

assert_deprecated(...): Allows deprecated functions, classes, decorators in tests.

assert_eigengate_implements_consistent_protocols(...): Checks that an EigenGate subclass is internally consistent and has a

assert_equivalent_computational_basis_map(...): Ensure equivalence of basis state mapping.

assert_equivalent_repr(...): Checks that eval(repr(v)) == v.

assert_has_consistent_apply_unitary(...): Tests whether a value's _applyunitary is correct.

assert_has_consistent_apply_unitary_for_various_exponents(...): Tests whether a value's _applyunitary is correct.

assert_has_consistent_qid_shape(...): Tests whether a value's _qid_shape_ and _num_qubits_ are correct and

assert_has_consistent_trace_distance_bound(...)

assert_has_diagram(...): Determines if a given circuit has the desired text diagram.

assert_implements_consistent_protocols(...): Checks that a value is internally consistent and has a good repr.

assert_json_roundtrip_works(...): Tests that the given object can serialized and de-serialized

assert_logs(...): A context manager for testing logging and warning events.

assert_pauli_expansion_is_consistent_with_unitary(...): Checks Pauli expansion against unitary matrix.

assert_phase_by_is_consistent_with_unitary(...): Uses val._unitary_ to check val._phase_by_'s behavior.

assert_qasm_is_consistent_with_unitary(...): Uses val._unitary_ to check val._qasm_'s behavior.

assert_same_circuits(...): Asserts that two circuits are identical, with a descriptive error.

assert_specifies_has_unitary_if_unitary(...): Checks that unitary values can be cheaply identifies as unitary.

asyncio_pending(...): Gives the given future a chance to complete, and determines if it didn't.

highlight_text_differences(...)

nonoptimal_toffoli_circuit(...)

random_circuit(...): Generates a random circuit.

random_density_matrix(...): Returns a random density matrix distributed with Hilbert-Schmidt measure.

random_orthogonal(...): Returns a random orthogonal matrix distributed with Haar measure.

random_special_orthogonal(...): Returns a random special orthogonal matrix distributed with Haar measure.

random_special_unitary(...): Returns a random special unitary distributed with Haar measure.

random_superposition(...): Returns a random unit-length vector from the uniform distribution.

random_two_qubit_circuit_with_czs(...): Creates a random two qubit circuit with the given number of CNOTs.

random_unitary(...): Returns a random unitary matrix distributed with Haar measure.

DEFAULT_GATE_DOMAIN The default gate domain for cirq.testing.random_circuit.

This includes the gates CNOT, CZ, H, ISWAP, CZ, S, SWAP, T, X, Y, and Z gates.