示例#1
0
def test_asymmetric_depolarizing_channel():
    d = cirq.asymmetric_depolarize(0.1, 0.2, 0.3)
    np.testing.assert_almost_equal(
        cirq.kraus(d),
        (np.sqrt(0.4) * np.eye(2), np.sqrt(0.1) * X, np.sqrt(0.2) * Y,
         np.sqrt(0.3) * Z),
    )
    assert cirq.has_kraus(d)

    assert cirq.AsymmetricDepolarizingChannel(p_x=0, p_y=0.1,
                                              p_z=0).num_qubits() == 1
示例#2
0
def get_supported_channels():
    """A helper to get the channels that are supported in TFQ.

    Returns a dictionary mapping from supported channel types
    to number of qubits.
    """
    # Add new channels here whenever additional support is needed.
    channel_mapping = dict()
    channel_mapping[cirq.DepolarizingChannel(0.01)] = 1
    channel_mapping[cirq.AsymmetricDepolarizingChannel(0.01, 0.02, 0.03)] = 1

    return channel_mapping
示例#3
0
def test_asymmetric_depolarizing_channel_repr():
    cirq.testing.assert_equivalent_repr(
        cirq.AsymmetricDepolarizingChannel(0.1, 0.2, 0.3))
示例#4
0
def test_multi_asymmetric_depolarizing_channel_repr():
    cirq.testing.assert_equivalent_repr(
        cirq.AsymmetricDepolarizingChannel(error_probabilities={
            'II': 0.8,
            'XX': 0.2
        }))
示例#5
0
文件: json_test.py 项目: c-poole/Cirq
    buffer.seek(0)

    with pytest.raises(ValueError) as e:
        cirq.read_json(buffer)
    assert e.match("Could not resolve type 'MyCustomClass' "
                   "during deserialization")


QUBITS = cirq.LineQubit.range(5)
Q0, Q1, Q2, Q3, Q4 = QUBITS

TEST_OBJECTS = {
    'AmplitudeDampingChannel':
    cirq.AmplitudeDampingChannel(0.5),
    'AsymmetricDepolarizingChannel':
    cirq.AsymmetricDepolarizingChannel(0.1, 0.2, 0.3),
    'BitFlipChannel':
    cirq.BitFlipChannel(0.5),
    'Bristlecone':
    cirq.google.Bristlecone,
    'CCNOT':
    cirq.CCNOT,
    'CCX':
    cirq.CCX,
    'CCXPowGate':
    cirq.CCXPowGate(exponent=0.123, global_shift=0.456),
    'CCZ':
    cirq.CCZ,
    'CCZPowGate':
    cirq.CCZPowGate(exponent=0.123, global_shift=0.456),
    'CNOT':
示例#6
0
def test_asymmetric_depolarizing_channel_apply_two_qubits():
    q0, q1 = cirq.LineQubit.range(2)
    op = cirq.AsymmetricDepolarizingChannel(error_probabilities={'XX': 0.1})
    op(q0, q1)