Exemplo n.º 1
0
    def test_mix_direct_and_deferred(self):
        sdm = SparseDM(1)

        sdm.rotate_y(0, np.pi)
        sdm.apply_ptm(0, ptm.amp_ph_damping_ptm(1, 0))
        sdm.rotate_y(0, np.pi)

        sdm.project_measurement(0, 0)

        assert not np.allclose(sdm.trace(), 1)
Exemplo n.º 2
0
def test_peak_on_hadamard():
    sdm = SparseDM(1)

    hadamard = ptm.hadamard_ptm()
    sdm.apply_ptm(0, hadamard)

    p0, p1 = sdm.peak_measurement(0)

    assert np.allclose(p0, 0.5)
    assert np.allclose(p1, 0.5)
Exemplo n.º 3
0
    def test_deferred_apply(self):
        sdm = SparseDM(1)

        assert 0 in sdm.classical

        p = ptm.hadamard_ptm()
        sdm.apply_ptm(0, p)

        assert 0 in sdm.classical
        assert 0 in sdm.single_ptms_to_do

        sdm.combine_and_apply_single_ptm(0)

        assert 0 not in sdm.classical

        assert 0 not in sdm.single_ptms_to_do