def test_noisy_basis_add_bad_types(): rng = np.random.RandomState(seed=1) noisy_basis = NoisyBasis( NoisyOperation.from_cirq(ideal=cirq.I, real=rng.rand(4, 4)), NoisyOperation.from_cirq(ideal=cirq.X, real=rng.rand(4, 4)), ) with pytest.raises(TypeError, match="All basis elements must be of type"): noisy_basis.add(cirq.Y)
def test_noisy_basis_add(): rng = np.random.RandomState(seed=1) noisy_basis = NoisyBasis( NoisyOperation.from_cirq(ideal=cirq.I, real=rng.rand(4, 4)), NoisyOperation.from_cirq(ideal=cirq.X, real=rng.rand(4, 4)), ) assert len(noisy_basis) == 2 noisy_basis.add( NoisyOperation.from_cirq(ideal=cirq.Y, real=rng.rand(4, 4)), NoisyOperation.from_cirq(ideal=cirq.Z, real=rng.rand(4, 4)), ) assert len(noisy_basis) == 4
def test_noisy_basis_add(): rng = np.random.RandomState(seed=1) noisy_basis = NoisyBasis( NoisyOperation.from_cirq(circuit=cirq.I, channel_matrix=rng.rand(4, 4)), NoisyOperation.from_cirq(circuit=cirq.X, channel_matrix=rng.rand(4, 4)), ) assert len(noisy_basis) == 2 noisy_basis.add( NoisyOperation.from_cirq(circuit=cirq.Y, channel_matrix=rng.rand(4, 4)), NoisyOperation.from_cirq(circuit=cirq.Z, channel_matrix=rng.rand(4, 4)), ) assert len(noisy_basis) == 4