コード例 #1
0
ファイル: test_measurement.py プロジェクト: rfajri27/qutip-1
def test_measurement_statistics_observable_ind(op, state):
    """ measurement_statistics_observable: observables on basis
        states with targets. """

    evs1, ess_or_projs1, probs1 = measurement_statistics_observable(
        state, tensor(op, identity(2)))
    evs2, ess_or_projs2, probs2 = measurement_statistics_observable(
        state, op, targets=[0])
    np.testing.assert_almost_equal(evs1, evs2)
    for a, b in zip(ess_or_projs1, ess_or_projs2):
        assert isequal(a, b)
    np.testing.assert_almost_equal(probs1, probs2)
コード例 #2
0
ファイル: test_measurement.py プロジェクト: rfajri27/qutip-1
def test_measure_observable(op, state):
    """ measure_observable: basis states using different observables """
    evs, ess_or_projs, prob = measurement_statistics_observable(state, op)

    expected_measurements = EigenPairs(list(zip(evs, ess_or_projs)))
    for _ in range(10):
        assert (measure_observable(state, op) in expected_measurements)
コード例 #3
0
ファイル: test_measurement.py プロジェクト: rfajri27/qutip-1
def test_measurement_statistics_observable(op, state, pairs, probabilities):
    """ measurement_statistics_observable: observables on basis states. """

    evs, ess_or_projs, probs = measurement_statistics_observable(state, op)
    np.testing.assert_almost_equal(evs, pairs.eigenvalues)
    if state.isket:
        ess = ess_or_projs
        assert len(ess) == len(pairs.eigenstates)
        for a, b in zip(ess, pairs.eigenstates):
            assert (_equivalent(a, b))

    else:
        projs = ess_or_projs
        assert len(projs) == len(pairs.projectors)
        for a, b in zip(projs, pairs.projectors):
            assert (_equivalent(a, b))
    np.testing.assert_almost_equal(probs, probabilities)