# pylint: disable=wrong-or-nonexistent-copyright-notice
import itertools
import math

import numpy as np
import pytest
import sympy

import cirq
import cirq.contrib.quimb as ccq
import cirq.testing
from cirq import value


def assert_same_output_as_dense(circuit, qubit_order, initial_state=0, grouping=None):
    mps_simulator = ccq.mps_simulator.MPSSimulator(grouping=grouping)
    ref_simulator = cirq.Simulator()

    actual = mps_simulator.simulate(circuit, qubit_order=qubit_order, initial_state=initial_state)
    expected = ref_simulator.simulate(circuit, qubit_order=qubit_order, initial_state=initial_state)
    np.testing.assert_allclose(
        actual.final_state.to_numpy(), expected.final_state_vector, atol=1e-4
    )
    assert len(actual.measurements) == 0


def test_various_gates_1d():
    gate_op_cls = [cirq.I, cirq.H, cirq.X, cirq.Y, cirq.Z, cirq.T]
    cross_gate_op_cls = [cirq.CNOT, cirq.SWAP]

    q0, q1 = cirq.LineQubit.range(2)

    for q0_gate_op in gate_op_cls:
        for q1_gate_op in gate_op_cls:
            for cross_gate_op in cross_gate_op_cls:
                circuit = cirq.Circuit(q0_gate_op(q0), q1_gate_op(q1), cross_gate_op(q0, q1))
                for initial_state in range(2 * 2):
                    assert_same_output_as_dense(
                        circuit=circuit, qubit_order=[q0, q1], initial_state=initial_state
                    )


def test_various_gates_1d_flip():
    q0, q1 = cirq.LineQubit.range(2)

    circuit = cirq.Circuit(cirq.H(q1), cirq.CNOT(q1, q0))

    assert_same_output_as_dense(circuit=circuit, qubit_order=[q0, q1])
    assert_same_output_as_dense(circuit=circuit, qubit_order=[q1, q0])


def test_various_gates_2d():
    gate_op_cls = [cirq.I, cirq.H]
    cross_gate_op_cls = [cirq.CNOT, cirq.SWAP]

    q0, q1, q2, q3, q4, q5 = cirq.GridQubit.rect(3, 2)

    for q0_gate_op in gate_op_cls:
        for q1_gate_op in gate_op_cls:
            for q2_gate_op in gate_op_cls:
                for q3_gate_op in gate_op_cls:
                    for cross_gate_op1 in cross_gate_op_cls:
                        for cross_gate_op2 in cross_gate_op_cls:
                            circuit = cirq.Circuit(
                                q0_gate_op(q0),
                                q1_gate_op(q1),
                                cross_gate_op1(q0, q1),
                                q2_gate_op(q2),
                                q3_gate_op(q3),
                                cross_gate_op2(q3, q1),
                            )
                            assert_same_output_as_dense(
                                circuit=circuit, qubit_order=[q0, q1, q2, q3, q4, q5]
                            )


def test_grouping():
    q0, q1, q2 = cirq.LineQubit.range(3)

    circuit = cirq.Circuit(
        cirq.X(q0) ** 0.1,
        cirq.Y(q1) ** 0.2,
        cirq.Z(q2) ** 0.3,
        cirq.CNOT(q0, q1),
        cirq.Y(q1) ** 0.4,
    )

    groupings = [
        None,
        {q0: 0, q1: 1, q2: 2},
        {q0: 0, q1: 0, q2: 1},
        {q0: 0, q1: 1, q2: 0},
        {q0: 1, q1: 0, q2: 0},
        {q0: 0, q1: 0, q2: 0},
    ]

    for grouping in groupings:
        for initial_state in range(2 * 2 * 2):
            assert_same_output_as_dense(
                circuit=circuit,
                qubit_order=[q0, q1, q2],
                initial_state=initial_state,
                grouping=grouping,
            )


def test_grouping_does_not_overlap():
    q0, q1 = cirq.LineQubit.range(2)
    mps_simulator = ccq.mps_simulator.MPSSimulator(grouping={q0: 0})

    with pytest.raises(ValueError, match="Grouping must cover exactly the qubits"):
        mps_simulator.simulate(cirq.Circuit(), qubit_order={q0: 0, q1: 1})


def test_same_partial_trace():
    qubit_order = cirq.LineQubit.range(2)
    q0, q1 = qubit_order

    mps_simulator = ccq.mps_simulator.MPSSimulator()

    for _ in range(50):
        for initial_state in range(4):
            circuit = cirq.testing.random_circuit(qubit_order, 3, 0.9)
            expected_density_matrix = cirq.final_density_matrix(
                circuit, qubit_order=qubit_order, initial_state=initial_state
            )
            expected_partial_trace = cirq.partial_trace(
                expected_density_matrix.reshape(2, 2, 2, 2), keep_indices=[0]
            )

            final_state = mps_simulator.simulate(
                circuit, qubit_order=qubit_order, initial_state=initial_state
            ).final_state
            actual_density_matrix = final_state.partial_trace([q0, q1])
            actual_partial_trace = final_state.partial_trace([q0])

            np.testing.assert_allclose(actual_density_matrix, expected_density_matrix, atol=1e-4)
            np.testing.assert_allclose(actual_partial_trace, expected_partial_trace, atol=1e-4)


def test_probs_dont_sum_up_to_one():
    q0 = cirq.NamedQid('q0', dimension=2)
    circuit = cirq.Circuit(cirq.measure(q0))

    simulator = ccq.mps_simulator.MPSSimulator(
        simulation_options=ccq.mps_simulator.MPSOptions(sum_prob_atol=-0.5)
    )

    with pytest.raises(ValueError, match="Sum of probabilities exceeds tolerance"):
        simulator.run(circuit, repetitions=1)


def test_empty():
    q0 = cirq.NamedQid('q0', dimension=2)
    q1 = cirq.NamedQid('q1', dimension=3)
    q2 = cirq.NamedQid('q2', dimension=5)
    circuit = cirq.Circuit()

    for initial_state in range(2 * 3 * 5):
        assert_same_output_as_dense(
            circuit=circuit, qubit_order=[q0, q1, q2], initial_state=initial_state
        )


def test_cnot():
    q0, q1 = cirq.LineQubit.range(2)
    circuit = cirq.Circuit(cirq.CNOT(q0, q1))

    for initial_state in range(4):
        assert_same_output_as_dense(
            circuit=circuit, qubit_order=[q0, q1], initial_state=initial_state
        )


def test_cnot_flipped():
    q0, q1 = cirq.LineQubit.range(2)
    circuit = cirq.Circuit(cirq.CNOT(q1, q0))

    for initial_state in range(4):
        assert_same_output_as_dense(
            circuit=circuit, qubit_order=[q0, q1], initial_state=initial_state
        )


def test_simulation_state():
    q0, q1 = qubit_order = cirq.LineQubit.range(2)
    circuit = cirq.Circuit(cirq.CNOT(q1, q0))
    mps_simulator = ccq.mps_simulator.MPSSimulator()
    ref_simulator = cirq.Simulator()
    for initial_state in range(4):
        args = mps_simulator._create_simulation_state(initial_state=initial_state, qubits=(q0, q1))
        actual = mps_simulator.simulate(circuit, qubit_order=qubit_order, initial_state=args)
        expected = ref_simulator.simulate(
            circuit, qubit_order=qubit_order, initial_state=initial_state
        )
        np.testing.assert_allclose(
            actual.final_state.to_numpy(), expected.final_state_vector, atol=1e-4
        )
        assert len(actual.measurements) == 0


def test_three_qubits():
    q0, q1, q2 = cirq.LineQubit.range(3)
    circuit = cirq.Circuit(cirq.CCX(q0, q1, q2))

    with pytest.raises(ValueError, match="Can only handle 1 and 2 qubit operations"):
        assert_same_output_as_dense(circuit=circuit, qubit_order=[q0, q1, q2])


def test_measurement_1qubit():
    q0, q1 = cirq.LineQubit.range(2)
    circuit = cirq.Circuit(cirq.X(q0), cirq.H(q1), cirq.measure(q1))

    simulator = ccq.mps_simulator.MPSSimulator()

    result = simulator.run(circuit, repetitions=100)
    assert sum(result.measurements['q(1)'])[0] < 80
    assert sum(result.measurements['q(1)'])[0] > 20


def test_reset():
    q = cirq.LineQubit(0)
    simulator = ccq.mps_simulator.MPSSimulator()
    c = cirq.Circuit(cirq.X(q), cirq.reset(q), cirq.measure(q))
    assert simulator.sample(c)['q(0)'][0] == 0
    c = cirq.Circuit(cirq.H(q), cirq.reset(q), cirq.measure(q))
    assert simulator.sample(c)['q(0)'][0] == 0
    c = cirq.Circuit(cirq.reset(q), cirq.measure(q))
    assert simulator.sample(c)['q(0)'][0] == 0


def test_measurement_2qubits():
    q0, q1, q2 = cirq.LineQubit.range(3)
    circuit = cirq.Circuit(cirq.H(q0), cirq.H(q1), cirq.H(q2), cirq.measure(q0, q2))

    simulator = ccq.mps_simulator.MPSSimulator()

    repetitions = 1024
    measurement = simulator.run(circuit, repetitions=repetitions).measurements['q(0),q(2)']

    result_counts = {'00': 0, '01': 0, '10': 0, '11': 0}
    for i in range(repetitions):
        key = str(measurement[i, 0]) + str(measurement[i, 1])
        result_counts[key] += 1

    for result_count in result_counts.values():
        # Expected value is 1/4:
        assert result_count > repetitions * 0.15
        assert result_count < repetitions * 0.35


def test_measurement_str():
    q0 = cirq.NamedQid('q0', dimension=3)
    circuit = cirq.Circuit(cirq.measure(q0))

    simulator = ccq.mps_simulator.MPSSimulator()
    result = simulator.run(circuit, repetitions=7)

    assert str(result) == "q0 (d=3)=0000000"


def test_trial_result_str():
    q0 = cirq.LineQubit(0)
    final_simulator_state = ccq.mps_simulator.MPSState(
        qubits=(q0,),
        prng=value.parse_random_state(0),
        simulation_options=ccq.mps_simulator.MPSOptions(),
    )
    result = ccq.mps_simulator.MPSTrialResult(
        params=cirq.ParamResolver({}),
        measurements={'m': np.array([[1]])},
        final_simulator_state=final_simulator_state,
    )
    assert 'output state: TensorNetwork' in str(result)


def test_trial_result_repr_pretty():
    q0 = cirq.LineQubit(0)
    final_simulator_state = ccq.mps_simulator.MPSState(
        qubits=(q0,),
        prng=value.parse_random_state(0),
        simulation_options=ccq.mps_simulator.MPSOptions(),
    )
    result = ccq.mps_simulator.MPSTrialResult(
        params=cirq.ParamResolver({}),
        measurements={'m': np.array([[1]])},
        final_simulator_state=final_simulator_state,
    )
    cirq.testing.assert_repr_pretty_contains(result, 'output state: TensorNetwork')
    cirq.testing.assert_repr_pretty(result, "cirq.MPSTrialResult(...)", cycle=True)


def test_empty_step_result():
    q0 = cirq.LineQubit(0)
    sim = ccq.mps_simulator.MPSSimulator()
    step_result = next(sim.simulate_moment_steps(cirq.Circuit(cirq.measure(q0))))
    assert 'TensorNetwork' in str(step_result)


def test_step_result_repr_pretty():
    q0 = cirq.LineQubit(0)
    sim = ccq.mps_simulator.MPSSimulator()
    step_result = next(sim.simulate_moment_steps(cirq.Circuit(cirq.measure(q0))))
    cirq.testing.assert_repr_pretty_contains(step_result, 'TensorNetwork')
    cirq.testing.assert_repr_pretty(step_result, "cirq.MPSSimulatorStepResult(...)", cycle=True)


def test_state_equal():
    q0, q1 = cirq.LineQubit.range(2)
    state0 = ccq.mps_simulator.MPSState(
        qubits=(q0,),
        prng=value.parse_random_state(0),
        simulation_options=ccq.mps_simulator.MPSOptions(cutoff=1e-3, sum_prob_atol=1e-3),
    )
    state1a = ccq.mps_simulator.MPSState(
        qubits=(q1,),
        prng=value.parse_random_state(0),
        simulation_options=ccq.mps_simulator.MPSOptions(cutoff=1e-3, sum_prob_atol=1e-3),
    )
    state1b = ccq.mps_simulator.MPSState(
        qubits=(q1,),
        prng=value.parse_random_state(0),
        simulation_options=ccq.mps_simulator.MPSOptions(cutoff=1729.0, sum_prob_atol=1e-3),
    )
    assert state0 == state0
    assert state0 != state1a
    assert state1a != state1b


def test_random_circuits_equal_more_rows():
    circuit = cirq.testing.random_circuit(
        qubits=cirq.GridQubit.rect(3, 2), n_moments=6, op_density=1.0
    )
    qubits = circuit.all_qubits()
    assert_same_output_as_dense(circuit, qubits)


def test_supremacy_equal_more_cols():
    circuit = cirq.testing.random_circuit(
        qubits=cirq.GridQubit.rect(2, 3), n_moments=6, op_density=1.0
    )
    qubits = circuit.all_qubits()
    assert_same_output_as_dense(circuit, qubits)


def test_tensor_index_names():
    qubits = cirq.LineQubit.range(12)
    qubit_map = {qubit: i for i, qubit in enumerate(qubits)}
    state = ccq.mps_simulator.MPSState(qubits=qubit_map, prng=value.parse_random_state(0))

    assert state.i_str(0) == "i_00"
    assert state.i_str(11) == "i_11"
    assert state.mu_str(0, 3) == "mu_0_3"
    assert state.mu_str(3, 0) == "mu_0_3"


def test_simulate_moment_steps_sample():
    q0, q1 = cirq.LineQubit.range(2)
    circuit = cirq.Circuit(cirq.H(q0), cirq.CNOT(q0, q1))

    simulator = ccq.mps_simulator.MPSSimulator()

    for i, step in enumerate(simulator.simulate_moment_steps(circuit)):
        if i == 0:
            np.testing.assert_almost_equal(
                step._simulator_state().to_numpy(),
                np.asarray([1.0 / math.sqrt(2), 0.0, 1.0 / math.sqrt(2), 0.0]),
            )
            # There are two "Tensor()" copies in the string.
            assert len(str(step).split('Tensor(')) == 3
            samples = step.sample([q0, q1], repetitions=10)
            for sample in samples:
                assert np.array_equal(sample, [True, False]) or np.array_equal(
                    sample, [False, False]
                )
            np.testing.assert_almost_equal(
                step._simulator_state().to_numpy(),
                np.asarray([1.0 / math.sqrt(2), 0.0, 1.0 / math.sqrt(2), 0.0]),
            )
        else:
            np.testing.assert_almost_equal(
                step._simulator_state().to_numpy(),
                np.asarray([1.0 / math.sqrt(2), 0.0, 0.0, 1.0 / math.sqrt(2)]),
            )
            # There are two "Tensor()" copies in the string.
            assert len(str(step).split('Tensor(')) == 3
            samples = step.sample([q0, q1], repetitions=10)
            for sample in samples:
                assert np.array_equal(sample, [True, True]) or np.array_equal(
                    sample, [False, False]
                )


def test_sample_seed():
    q = cirq.NamedQubit('q')
    circuit = cirq.Circuit(cirq.H(q), cirq.measure(q))
    simulator = ccq.mps_simulator.MPSSimulator(seed=1234)
    result = simulator.run(circuit, repetitions=20)
    measured = result.measurements['q']
    result_string = ''.join(map(lambda x: str(int(x[0])), measured))
    assert result_string == '01011001110111011011'


def test_run_no_repetitions():
    q0 = cirq.LineQubit(0)
    simulator = ccq.mps_simulator.MPSSimulator()
    circuit = cirq.Circuit(cirq.H(q0), cirq.measure(q0))
    result = simulator.run(circuit, repetitions=0)
    assert len(result.measurements['q(0)']) == 0


def test_run_parameters_not_resolved():
    a = cirq.LineQubit(0)
    simulator = ccq.mps_simulator.MPSSimulator()
    circuit = cirq.Circuit(cirq.XPowGate(exponent=sympy.Symbol('a'))(a), cirq.measure(a))
    with pytest.raises(ValueError, match='symbols were not specified'):
        _ = simulator.run_sweep(circuit, cirq.ParamResolver({}))


def test_deterministic_gate_noise():
    q = cirq.LineQubit(0)
    circuit = cirq.Circuit(cirq.I(q), cirq.measure(q))

    simulator1 = ccq.mps_simulator.MPSSimulator(noise=cirq.X)
    result1 = simulator1.run(circuit, repetitions=10)

    simulator2 = ccq.mps_simulator.MPSSimulator(noise=cirq.X)
    result2 = simulator2.run(circuit, repetitions=10)

    assert result1 == result2

    simulator3 = ccq.mps_simulator.MPSSimulator(noise=cirq.Z)
    result3 = simulator3.run(circuit, repetitions=10)

    assert result1 != result3


def test_nondeterministic_mixture_noise():
    q = cirq.LineQubit(0)
    circuit = cirq.Circuit(cirq.I(q), cirq.measure(q))

    simulator = ccq.mps_simulator.MPSSimulator(
        noise=cirq.ConstantQubitNoiseModel(cirq.depolarize(0.5))
    )
    result1 = simulator.run(circuit, repetitions=50)
    result2 = simulator.run(circuit, repetitions=50)

    assert result1 != result2


def test_unsupported_noise_fails():
    with pytest.raises(ValueError, match='noise must be unitary or mixture but was'):
        ccq.mps_simulator.MPSSimulator(noise=cirq.amplitude_damp(0.5))


def test_state_copy():
    sim = ccq.mps_simulator.MPSSimulator()

    q = cirq.LineQubit(0)
    circuit = cirq.Circuit(cirq.H(q), cirq.H(q))

    state_Ms = []
    for step in sim.simulate_moment_steps(circuit):
        state_Ms.append(step.state.M)
    for x, y in itertools.combinations(state_Ms, 2):
        assert len(x) == len(y)
        for i in range(len(x)):
            assert not np.shares_memory(x[i], y[i])


def test_simulation_state_initializer():
    s = ccq.mps_simulator.MPSState(
        qubits=(cirq.LineQubit(0),),
        prng=np.random.RandomState(0),
        classical_data=cirq.ClassicalDataDictionaryStore(
            _records={cirq.MeasurementKey('test'): [(4,)]}
        ),
    )
    assert s.qubits == (cirq.LineQubit(0),)
    assert s.log_of_measurement_results == {'test': [4]}


def test_act_on_gate():
    args = ccq.mps_simulator.MPSState(qubits=cirq.LineQubit.range(3), prng=np.random.RandomState(0))

    cirq.act_on(cirq.X, args, [cirq.LineQubit(1)])
    np.testing.assert_allclose(
        args.state_vector().reshape((2, 2, 2)),
        cirq.one_hot(index=(0, 1, 0), shape=(2, 2, 2), dtype=np.complex64),
    )


def test_deprecated():
    prng = np.random.RandomState(0)
    with cirq.testing.assert_deprecated('log_of_measurement_results', deadline='0.16', count=2):
        _ = ccq.mps_simulator.MPSState(
            qubits=cirq.LineQubit.range(3), prng=prng, log_of_measurement_results={}
        )
    with cirq.testing.assert_deprecated('positional', deadline='0.16'):
        _ = ccq.mps_simulator.MPSState(cirq.LineQubit.range(3), prng=prng)

[((330, 379), 'cirq.contrib.quimb.mps_simulator.MPSSimulator', 'ccq.mps_simulator.MPSSimulator', ([], {'grouping': 'grouping'}), '(grouping=grouping)\n', (360, 379), True, 'import cirq.contrib.quimb as ccq\n'), ((400, 416), 'cirq.Simulator', 'cirq.Simulator', ([], {}), '()\n', (414, 416), False, 'import cirq\n'), ((934, 957), 'cirq.LineQubit.range', 'cirq.LineQubit.range', (['(2)'], {}), '(2)\n', (954, 957), False, 'import cirq\n'), ((1441, 1464), 'cirq.LineQubit.range', 'cirq.LineQubit.range', (['(2)'], {}), '(2)\n', (1461, 1464), False, 'import cirq\n'), ((1810, 1835), 'cirq.GridQubit.rect', 'cirq.GridQubit.rect', (['(3)', '(2)'], {}), '(3, 2)\n', (1829, 1835), False, 'import cirq\n'), ((2726, 2749), 'cirq.LineQubit.range', 'cirq.LineQubit.range', (['(3)'], {}), '(3)\n', (2746, 2749), False, 'import cirq\n'), ((3456, 3479), 'cirq.LineQubit.range', 'cirq.LineQubit.range', (['(2)'], {}), '(2)\n', (3476, 3479), False, 'import cirq\n'), ((3500, 3548), 'cirq.contrib.quimb.mps_simulator.MPSSimulator', 'ccq.mps_simulator.MPSSimulator', ([], {'grouping': '{q0: 0}'}), '(grouping={q0: 0})\n', (3530, 3548), True, 'import cirq.contrib.quimb as ccq\n'), ((3760, 3783), 'cirq.LineQubit.range', 'cirq.LineQubit.range', (['(2)'], {}), '(2)\n', (3780, 3783), False, 'import cirq\n'), ((3830, 3862), 'cirq.contrib.quimb.mps_simulator.MPSSimulator', 'ccq.mps_simulator.MPSSimulator', ([], {}), '()\n', (3860, 3862), True, 'import cirq.contrib.quimb as ccq\n'), ((4841, 4873), 'cirq.NamedQid', 'cirq.NamedQid', (['"""q0"""'], {'dimension': '(2)'}), "('q0', dimension=2)\n", (4854, 4873), False, 'import cirq\n'), ((5210, 5242), 'cirq.NamedQid', 'cirq.NamedQid', (['"""q0"""'], {'dimension': '(2)'}), "('q0', dimension=2)\n", (5223, 5242), False, 'import cirq\n'), ((5252, 5284), 'cirq.NamedQid', 'cirq.NamedQid', (['"""q1"""'], {'dimension': '(3)'}), "('q1', dimension=3)\n", (5265, 5284), False, 'import cirq\n'), ((5294, 5326), 'cirq.NamedQid', 'cirq.NamedQid', (['"""q2"""'], {'dimension': '(5)'}), "('q2', dimension=5)\n", (5307, 5326), False, 'import cirq\n'), ((5341, 5355), 'cirq.Circuit', 'cirq.Circuit', ([], {}), '()\n', (5353, 5355), False, 'import cirq\n'), ((5562, 5585), 'cirq.LineQubit.range', 'cirq.LineQubit.range', (['(2)'], {}), '(2)\n', (5582, 5585), False, 'import cirq\n'), ((5834, 5857), 'cirq.LineQubit.range', 'cirq.LineQubit.range', (['(2)'], {}), '(2)\n', (5854, 5857), False, 'import cirq\n'), ((6124, 6147), 'cirq.LineQubit.range', 'cirq.LineQubit.range', (['(2)'], {}), '(2)\n', (6144, 6147), False, 'import cirq\n'), ((6214, 6246), 'cirq.contrib.quimb.mps_simulator.MPSSimulator', 'ccq.mps_simulator.MPSSimulator', ([], {}), '()\n', (6244, 6246), True, 'import cirq.contrib.quimb as ccq\n'), ((6267, 6283), 'cirq.Simulator', 'cirq.Simulator', ([], {}), '()\n', (6281, 6283), False, 'import cirq\n'), ((6857, 6880), 'cirq.LineQubit.range', 'cirq.LineQubit.range', (['(3)'], {}), '(3)\n', (6877, 6880), False, 'import cirq\n'), ((7142, 7165), 'cirq.LineQubit.range', 'cirq.LineQubit.range', (['(2)'], {}), '(2)\n', (7162, 7165), False, 'import cirq\n'), ((7252, 7284), 'cirq.contrib.quimb.mps_simulator.MPSSimulator', 'ccq.mps_simulator.MPSSimulator', ([], {}), '()\n', (7282, 7284), True, 'import cirq.contrib.quimb as ccq\n'), ((7471, 7488), 'cirq.LineQubit', 'cirq.LineQubit', (['(0)'], {}), '(0)\n', (7485, 7488), False, 'import cirq\n'), ((7505, 7537), 'cirq.contrib.quimb.mps_simulator.MPSSimulator', 'ccq.mps_simulator.MPSSimulator', ([], {}), '()\n', (7535, 7537), True, 'import cirq.contrib.quimb as ccq\n'), ((7911, 7934), 'cirq.LineQubit.range', 'cirq.LineQubit.range', (['(3)'], {}), '(3)\n', (7931, 7934), False, 'import cirq\n'), ((8037, 8069), 'cirq.contrib.quimb.mps_simulator.MPSSimulator', 'ccq.mps_simulator.MPSSimulator', ([], {}), '()\n', (8067, 8069), True, 'import cirq.contrib.quimb as ccq\n'), ((8590, 8622), 'cirq.NamedQid', 'cirq.NamedQid', (['"""q0"""'], {'dimension': '(3)'}), "('q0', dimension=3)\n", (8603, 8622), False, 'import cirq\n'), ((8685, 8717), 'cirq.contrib.quimb.mps_simulator.MPSSimulator', 'ccq.mps_simulator.MPSSimulator', ([], {}), '()\n', (8715, 8717), True, 'import cirq.contrib.quimb as ccq\n'), ((8855, 8872), 'cirq.LineQubit', 'cirq.LineQubit', (['(0)'], {}), '(0)\n', (8869, 8872), False, 'import cirq\n'), ((9352, 9369), 'cirq.LineQubit', 'cirq.LineQubit', (['(0)'], {}), '(0)\n', (9366, 9369), False, 'import cirq\n'), ((9749, 9828), 'cirq.testing.assert_repr_pretty_contains', 'cirq.testing.assert_repr_pretty_contains', (['result', '"""output state: TensorNetwork"""'], {}), "(result, 'output state: TensorNetwork')\n", (9789, 9828), False, 'import cirq\n'), ((9833, 9912), 'cirq.testing.assert_repr_pretty', 'cirq.testing.assert_repr_pretty', (['result', '"""cirq.MPSTrialResult(...)"""'], {'cycle': '(True)'}), "(result, 'cirq.MPSTrialResult(...)', cycle=True)\n", (9864, 9912), False, 'import cirq\n'), ((9954, 9971), 'cirq.LineQubit', 'cirq.LineQubit', (['(0)'], {}), '(0)\n', (9968, 9971), False, 'import cirq\n'), ((9982, 10014), 'cirq.contrib.quimb.mps_simulator.MPSSimulator', 'ccq.mps_simulator.MPSSimulator', ([], {}), '()\n', (10012, 10014), True, 'import cirq.contrib.quimb as ccq\n'), ((10191, 10208), 'cirq.LineQubit', 'cirq.LineQubit', (['(0)'], {}), '(0)\n', (10205, 10208), False, 'import cirq\n'), ((10219, 10251), 'cirq.contrib.quimb.mps_simulator.MPSSimulator', 'ccq.mps_simulator.MPSSimulator', ([], {}), '()\n', (10249, 10251), True, 'import cirq.contrib.quimb as ccq\n'), ((10338, 10408), 'cirq.testing.assert_repr_pretty_contains', 'cirq.testing.assert_repr_pretty_contains', (['step_result', '"""TensorNetwork"""'], {}), "(step_result, 'TensorNetwork')\n", (10378, 10408), False, 'import cirq\n'), ((10413, 10509), 'cirq.testing.assert_repr_pretty', 'cirq.testing.assert_repr_pretty', (['step_result', '"""cirq.MPSSimulatorStepResult(...)"""'], {'cycle': '(True)'}), "(step_result,\n    'cirq.MPSSimulatorStepResult(...)', cycle=True)\n", (10444, 10509), False, 'import cirq\n'), ((10545, 10568), 'cirq.LineQubit.range', 'cirq.LineQubit.range', (['(2)'], {}), '(2)\n', (10565, 10568), False, 'import cirq\n'), ((11799, 11823), 'cirq.LineQubit.range', 'cirq.LineQubit.range', (['(12)'], {}), '(12)\n', (11819, 11823), False, 'import cirq\n'), ((12190, 12213), 'cirq.LineQubit.range', 'cirq.LineQubit.range', (['(2)'], {}), '(2)\n', (12210, 12213), False, 'import cirq\n'), ((12289, 12321), 'cirq.contrib.quimb.mps_simulator.MPSSimulator', 'ccq.mps_simulator.MPSSimulator', ([], {}), '()\n', (12319, 12321), True, 'import cirq.contrib.quimb as ccq\n'), ((13737, 13757), 'cirq.NamedQubit', 'cirq.NamedQubit', (['"""q"""'], {}), "('q')\n", (13752, 13757), False, 'import cirq\n'), ((13829, 13870), 'cirq.contrib.quimb.mps_simulator.MPSSimulator', 'ccq.mps_simulator.MPSSimulator', ([], {'seed': '(1234)'}), '(seed=1234)\n', (13859, 13870), True, 'import cirq.contrib.quimb as ccq\n'), ((14125, 14142), 'cirq.LineQubit', 'cirq.LineQubit', (['(0)'], {}), '(0)\n', (14139, 14142), False, 'import cirq\n'), ((14159, 14191), 'cirq.contrib.quimb.mps_simulator.MPSSimulator', 'ccq.mps_simulator.MPSSimulator', ([], {}), '()\n', (14189, 14191), True, 'import cirq.contrib.quimb as ccq\n'), ((14399, 14416), 'cirq.LineQubit', 'cirq.LineQubit', (['(0)'], {}), '(0)\n', (14413, 14416), False, 'import cirq\n'), ((14433, 14465), 'cirq.contrib.quimb.mps_simulator.MPSSimulator', 'ccq.mps_simulator.MPSSimulator', ([], {}), '()\n', (14463, 14465), True, 'import cirq.contrib.quimb as ccq\n'), ((14740, 14757), 'cirq.LineQubit', 'cirq.LineQubit', (['(0)'], {}), '(0)\n', (14754, 14757), False, 'import cirq\n'), ((14831, 14875), 'cirq.contrib.quimb.mps_simulator.MPSSimulator', 'ccq.mps_simulator.MPSSimulator', ([], {'noise': 'cirq.X'}), '(noise=cirq.X)\n', (14861, 14875), True, 'import cirq.contrib.quimb as ccq\n'), ((14948, 14992), 'cirq.contrib.quimb.mps_simulator.MPSSimulator', 'ccq.mps_simulator.MPSSimulator', ([], {'noise': 'cirq.X'}), '(noise=cirq.X)\n', (14978, 14992), True, 'import cirq.contrib.quimb as ccq\n'), ((15096, 15140), 'cirq.contrib.quimb.mps_simulator.MPSSimulator', 'ccq.mps_simulator.MPSSimulator', ([], {'noise': 'cirq.Z'}), '(noise=cirq.Z)\n', (15126, 15140), True, 'import cirq.contrib.quimb as ccq\n'), ((15279, 15296), 'cirq.LineQubit', 'cirq.LineQubit', (['(0)'], {}), '(0)\n', (15293, 15296), False, 'import cirq\n'), ((15839, 15871), 'cirq.contrib.quimb.mps_simulator.MPSSimulator', 'ccq.mps_simulator.MPSSimulator', ([], {}), '()\n', (15869, 15871), True, 'import cirq.contrib.quimb as ccq\n'), ((15881, 15898), 'cirq.LineQubit', 'cirq.LineQubit', (['(0)'], {}), '(0)\n', (15895, 15898), False, 'import cirq\n'), ((16073, 16108), 'itertools.combinations', 'itertools.combinations', (['state_Ms', '(2)'], {}), '(state_Ms, 2)\n', (16095, 16108), False, 'import itertools\n'), ((16993, 17017), 'numpy.random.RandomState', 'np.random.RandomState', (['(0)'], {}), '(0)\n', (17014, 17017), True, 'import numpy as np\n'), ((1493, 1503), 'cirq.H', 'cirq.H', (['q1'], {}), '(q1)\n', (1499, 1503), False, 'import cirq\n'), ((1505, 1522), 'cirq.CNOT', 'cirq.CNOT', (['q1', 'q0'], {}), '(q1, q0)\n', (1514, 1522), False, 'import cirq\n'), ((2868, 2885), 'cirq.CNOT', 'cirq.CNOT', (['q0', 'q1'], {}), '(q0, q1)\n', (2877, 2885), False, 'import cirq\n'), ((3559, 3632), 'pytest.raises', 'pytest.raises', (['ValueError'], {'match': '"""Grouping must cover exactly the qubits"""'}), "(ValueError, match='Grouping must cover exactly the qubits')\n", (3572, 3632), False, 'import pytest\n'), ((4901, 4917), 'cirq.measure', 'cirq.measure', (['q0'], {}), '(q0)\n', (4913, 4917), False, 'import cirq\n'), ((5060, 5133), 'pytest.raises', 'pytest.raises', (['ValueError'], {'match': '"""Sum of probabilities exceeds tolerance"""'}), "(ValueError, match='Sum of probabilities exceeds tolerance')\n", (5073, 5133), False, 'import pytest\n'), ((5613, 5630), 'cirq.CNOT', 'cirq.CNOT', (['q0', 'q1'], {}), '(q0, q1)\n', (5622, 5630), False, 'import cirq\n'), ((5885, 5902), 'cirq.CNOT', 'cirq.CNOT', (['q1', 'q0'], {}), '(q1, q0)\n', (5894, 5902), False, 'import cirq\n'), ((6175, 6192), 'cirq.CNOT', 'cirq.CNOT', (['q1', 'q0'], {}), '(q1, q0)\n', (6184, 6192), False, 'import cirq\n'), ((6908, 6928), 'cirq.CCX', 'cirq.CCX', (['q0', 'q1', 'q2'], {}), '(q0, q1, q2)\n', (6916, 6928), False, 'import cirq\n'), ((6940, 7015), 'pytest.raises', 'pytest.raises', (['ValueError'], {'match': '"""Can only handle 1 and 2 qubit operations"""'}), "(ValueError, match='Can only handle 1 and 2 qubit operations')\n", (6953, 7015), False, 'import pytest\n'), ((7193, 7203), 'cirq.X', 'cirq.X', (['q0'], {}), '(q0)\n', (7199, 7203), False, 'import cirq\n'), ((7205, 7215), 'cirq.H', 'cirq.H', (['q1'], {}), '(q1)\n', (7211, 7215), False, 'import cirq\n'), ((7217, 7233), 'cirq.measure', 'cirq.measure', (['q1'], {}), '(q1)\n', (7229, 7233), False, 'import cirq\n'), ((7559, 7568), 'cirq.X', 'cirq.X', (['q'], {}), '(q)\n', (7565, 7568), False, 'import cirq\n'), ((7570, 7583), 'cirq.reset', 'cirq.reset', (['q'], {}), '(q)\n', (7580, 7583), False, 'import cirq\n'), ((7585, 7600), 'cirq.measure', 'cirq.measure', (['q'], {}), '(q)\n', (7597, 7600), False, 'import cirq\n'), ((7670, 7679), 'cirq.H', 'cirq.H', (['q'], {}), '(q)\n', (7676, 7679), False, 'import cirq\n'), ((7681, 7694), 'cirq.reset', 'cirq.reset', (['q'], {}), '(q)\n', (7691, 7694), False, 'import cirq\n'), ((7696, 7711), 'cirq.measure', 'cirq.measure', (['q'], {}), '(q)\n', (7708, 7711), False, 'import cirq\n'), ((7781, 7794), 'cirq.reset', 'cirq.reset', (['q'], {}), '(q)\n', (7791, 7794), False, 'import cirq\n'), ((7796, 7811), 'cirq.measure', 'cirq.measure', (['q'], {}), '(q)\n', (7808, 7811), False, 'import cirq\n'), ((7962, 7972), 'cirq.H', 'cirq.H', (['q0'], {}), '(q0)\n', (7968, 7972), False, 'import cirq\n'), ((7974, 7984), 'cirq.H', 'cirq.H', (['q1'], {}), '(q1)\n', (7980, 7984), False, 'import cirq\n'), ((7986, 7996), 'cirq.H', 'cirq.H', (['q2'], {}), '(q2)\n', (7992, 7996), False, 'import cirq\n'), ((7998, 8018), 'cirq.measure', 'cirq.measure', (['q0', 'q2'], {}), '(q0, q2)\n', (8010, 8018), False, 'import cirq\n'), ((8650, 8666), 'cirq.measure', 'cirq.measure', (['q0'], {}), '(q0)\n', (8662, 8666), False, 'import cirq\n'), ((12241, 12251), 'cirq.H', 'cirq.H', (['q0'], {}), '(q0)\n', (12247, 12251), False, 'import cirq\n'), ((12253, 12270), 'cirq.CNOT', 'cirq.CNOT', (['q0', 'q1'], {}), '(q0, q1)\n', (12262, 12270), False, 'import cirq\n'), ((13785, 13794), 'cirq.H', 'cirq.H', (['q'], {}), '(q)\n', (13791, 13794), False, 'import cirq\n'), ((13796, 13811), 'cirq.measure', 'cirq.measure', (['q'], {}), '(q)\n', (13808, 13811), False, 'import cirq\n'), ((14219, 14229), 'cirq.H', 'cirq.H', (['q0'], {}), '(q0)\n', (14225, 14229), False, 'import cirq\n'), ((14231, 14247), 'cirq.measure', 'cirq.measure', (['q0'], {}), '(q0)\n', (14243, 14247), False, 'import cirq\n'), ((14539, 14554), 'cirq.measure', 'cirq.measure', (['a'], {}), '(a)\n', (14551, 14554), False, 'import cirq\n'), ((14565, 14626), 'pytest.raises', 'pytest.raises', (['ValueError'], {'match': '"""symbols were not specified"""'}), "(ValueError, match='symbols were not specified')\n", (14578, 14626), False, 'import pytest\n'), ((14785, 14794), 'cirq.I', 'cirq.I', (['q'], {}), '(q)\n', (14791, 14794), False, 'import cirq\n'), ((14796, 14811), 'cirq.measure', 'cirq.measure', (['q'], {}), '(q)\n', (14808, 14811), False, 'import cirq\n'), ((15324, 15333), 'cirq.I', 'cirq.I', (['q'], {}), '(q)\n', (15330, 15333), False, 'import cirq\n'), ((15335, 15350), 'cirq.measure', 'cirq.measure', (['q'], {}), '(q)\n', (15347, 15350), False, 'import cirq\n'), ((15656, 15731), 'pytest.raises', 'pytest.raises', (['ValueError'], {'match': '"""noise must be unitary or mixture but was"""'}), "(ValueError, match='noise must be unitary or mixture but was')\n", (15669, 15731), False, 'import pytest\n'), ((15926, 15935), 'cirq.H', 'cirq.H', (['q'], {}), '(q)\n', (15932, 15935), False, 'import cirq\n'), ((15937, 15946), 'cirq.H', 'cirq.H', (['q'], {}), '(q)\n', (15943, 15946), False, 'import cirq\n'), ((16883, 16949), 'cirq.one_hot', 'cirq.one_hot', ([], {'index': '(0, 1, 0)', 'shape': '(2, 2, 2)', 'dtype': 'np.complex64'}), '(index=(0, 1, 0), shape=(2, 2, 2), dtype=np.complex64)\n', (16895, 16949), False, 'import cirq\n'), ((17027, 17118), 'cirq.testing.assert_deprecated', 'cirq.testing.assert_deprecated', (['"""log_of_measurement_results"""'], {'deadline': '"""0.16"""', 'count': '(2)'}), "('log_of_measurement_results', deadline=\n    '0.16', count=2)\n", (17057, 17118), False, 'import cirq\n'), ((17259, 17320), 'cirq.testing.assert_deprecated', 'cirq.testing.assert_deprecated', (['"""positional"""'], {'deadline': '"""0.16"""'}), "('positional', deadline='0.16')\n", (17289, 17320), False, 'import cirq\n'), ((2787, 2797), 'cirq.X', 'cirq.X', (['q0'], {}), '(q0)\n', (2793, 2797), False, 'import cirq\n'), ((2814, 2824), 'cirq.Y', 'cirq.Y', (['q1'], {}), '(q1)\n', (2820, 2824), False, 'import cirq\n'), ((2841, 2851), 'cirq.Z', 'cirq.Z', (['q2'], {}), '(q2)\n', (2847, 2851), False, 'import cirq\n'), ((2895, 2905), 'cirq.Y', 'cirq.Y', (['q1'], {}), '(q1)\n', (2901, 2905), False, 'import cirq\n'), ((3665, 3679), 'cirq.Circuit', 'cirq.Circuit', ([], {}), '()\n', (3677, 3679), False, 'import cirq\n'), ((3949, 3997), 'cirq.testing.random_circuit', 'cirq.testing.random_circuit', (['qubit_order', '(3)', '(0.9)'], {}), '(qubit_order, 3, 0.9)\n', (3976, 3997), False, 'import cirq\n'), ((4036, 4129), 'cirq.final_density_matrix', 'cirq.final_density_matrix', (['circuit'], {'qubit_order': 'qubit_order', 'initial_state': 'initial_state'}), '(circuit, qubit_order=qubit_order, initial_state=\n    initial_state)\n', (4061, 4129), False, 'import cirq\n'), ((4611, 4702), 'numpy.testing.assert_allclose', 'np.testing.assert_allclose', (['actual_density_matrix', 'expected_density_matrix'], {'atol': '(0.0001)'}), '(actual_density_matrix, expected_density_matrix,\n    atol=0.0001)\n', (4637, 4702), True, 'import numpy as np\n'), ((4709, 4798), 'numpy.testing.assert_allclose', 'np.testing.assert_allclose', (['actual_partial_trace', 'expected_partial_trace'], {'atol': '(0.0001)'}), '(actual_partial_trace, expected_partial_trace,\n    atol=0.0001)\n', (4735, 4798), True, 'import numpy as np\n'), ((4995, 5043), 'cirq.contrib.quimb.mps_simulator.MPSOptions', 'ccq.mps_simulator.MPSOptions', ([], {'sum_prob_atol': '(-0.5)'}), '(sum_prob_atol=-0.5)\n', (5023, 5043), True, 'import cirq.contrib.quimb as ccq\n'), ((8964, 8991), 'cirq.value.parse_random_state', 'value.parse_random_state', (['(0)'], {}), '(0)\n', (8988, 8991), False, 'from cirq import value\n'), ((9020, 9050), 'cirq.contrib.quimb.mps_simulator.MPSOptions', 'ccq.mps_simulator.MPSOptions', ([], {}), '()\n', (9048, 9050), True, 'import cirq.contrib.quimb as ccq\n'), ((9120, 9142), 'cirq.ParamResolver', 'cirq.ParamResolver', (['{}'], {}), '({})\n', (9138, 9142), False, 'import cirq\n'), ((9461, 9488), 'cirq.value.parse_random_state', 'value.parse_random_state', (['(0)'], {}), '(0)\n', (9485, 9488), False, 'from cirq import value\n'), ((9517, 9547), 'cirq.contrib.quimb.mps_simulator.MPSOptions', 'ccq.mps_simulator.MPSOptions', ([], {}), '()\n', (9545, 9547), True, 'import cirq.contrib.quimb as ccq\n'), ((9617, 9639), 'cirq.ParamResolver', 'cirq.ParamResolver', (['{}'], {}), '({})\n', (9635, 9639), False, 'import cirq\n'), ((10645, 10672), 'cirq.value.parse_random_state', 'value.parse_random_state', (['(0)'], {}), '(0)\n', (10669, 10672), False, 'from cirq import value\n'), ((10701, 10764), 'cirq.contrib.quimb.mps_simulator.MPSOptions', 'ccq.mps_simulator.MPSOptions', ([], {'cutoff': '(0.001)', 'sum_prob_atol': '(0.001)'}), '(cutoff=0.001, sum_prob_atol=0.001)\n', (10729, 10764), True, 'import cirq.contrib.quimb as ccq\n'), ((10847, 10874), 'cirq.value.parse_random_state', 'value.parse_random_state', (['(0)'], {}), '(0)\n', (10871, 10874), False, 'from cirq import value\n'), ((10903, 10966), 'cirq.contrib.quimb.mps_simulator.MPSOptions', 'ccq.mps_simulator.MPSOptions', ([], {'cutoff': '(0.001)', 'sum_prob_atol': '(0.001)'}), '(cutoff=0.001, sum_prob_atol=0.001)\n', (10931, 10966), True, 'import cirq.contrib.quimb as ccq\n'), ((11049, 11076), 'cirq.value.parse_random_state', 'value.parse_random_state', (['(0)'], {}), '(0)\n', (11073, 11076), False, 'from cirq import value\n'), ((11105, 11169), 'cirq.contrib.quimb.mps_simulator.MPSOptions', 'ccq.mps_simulator.MPSOptions', ([], {'cutoff': '(1729.0)', 'sum_prob_atol': '(0.001)'}), '(cutoff=1729.0, sum_prob_atol=0.001)\n', (11133, 11169), True, 'import cirq.contrib.quimb as ccq\n'), ((11367, 11392), 'cirq.GridQubit.rect', 'cirq.GridQubit.rect', (['(3)', '(2)'], {}), '(3, 2)\n', (11386, 11392), False, 'import cirq\n'), ((11609, 11634), 'cirq.GridQubit.rect', 'cirq.GridQubit.rect', (['(2)', '(3)'], {}), '(2, 3)\n', (11628, 11634), False, 'import cirq\n'), ((11947, 11974), 'cirq.value.parse_random_state', 'value.parse_random_state', (['(0)'], {}), '(0)\n', (11971, 11974), False, 'from cirq import value\n'), ((14669, 14691), 'cirq.ParamResolver', 'cirq.ParamResolver', (['{}'], {}), '({})\n', (14687, 14691), False, 'import cirq\n'), ((16355, 16379), 'numpy.random.RandomState', 'np.random.RandomState', (['(0)'], {}), '(0)\n', (16376, 16379), True, 'import numpy as np\n'), ((16539, 16556), 'cirq.LineQubit', 'cirq.LineQubit', (['(0)'], {}), '(0)\n', (16553, 16556), False, 'import cirq\n'), ((16687, 16710), 'cirq.LineQubit.range', 'cirq.LineQubit.range', (['(3)'], {}), '(3)\n', (16707, 16710), False, 'import cirq\n'), ((16717, 16741), 'numpy.random.RandomState', 'np.random.RandomState', (['(0)'], {}), '(0)\n', (16738, 16741), True, 'import numpy as np\n'), ((16775, 16792), 'cirq.LineQubit', 'cirq.LineQubit', (['(1)'], {}), '(1)\n', (16789, 16792), False, 'import cirq\n'), ((17361, 17384), 'cirq.LineQubit.range', 'cirq.LineQubit.range', (['(3)'], {}), '(3)\n', (17381, 17384), False, 'import cirq\n'), ((9171, 9186), 'numpy.array', 'np.array', (['[[1]]'], {}), '([[1]])\n', (9179, 9186), True, 'import numpy as np\n'), ((9668, 9683), 'numpy.array', 'np.array', (['[[1]]'], {}), '([[1]])\n', (9676, 9683), True, 'import numpy as np\n'), ((10077, 10093), 'cirq.measure', 'cirq.measure', (['q0'], {}), '(q0)\n', (10089, 10093), False, 'import cirq\n'), ((10314, 10330), 'cirq.measure', 'cirq.measure', (['q0'], {}), '(q0)\n', (10326, 10330), False, 'import cirq\n'), ((15444, 15464), 'cirq.depolarize', 'cirq.depolarize', (['(0.5)'], {}), '(0.5)\n', (15459, 15464), False, 'import cirq\n'), ((15778, 15802), 'cirq.amplitude_damp', 'cirq.amplitude_damp', (['(0.5)'], {}), '(0.5)\n', (15797, 15802), False, 'import cirq\n'), ((16197, 16225), 'numpy.shares_memory', 'np.shares_memory', (['x[i]', 'y[i]'], {}), '(x[i], y[i])\n', (16213, 16225), True, 'import numpy as np\n'), ((16321, 16338), 'cirq.LineQubit', 'cirq.LineQubit', (['(0)'], {}), '(0)\n', (16335, 16338), False, 'import cirq\n'), ((17174, 17197), 'cirq.LineQubit.range', 'cirq.LineQubit.range', (['(3)'], {}), '(3)\n', (17194, 17197), False, 'import cirq\n'), ((12839, 12876), 'numpy.array_equal', 'np.array_equal', (['sample', '[True, False]'], {}), '(sample, [True, False])\n', (12853, 12876), True, 'import numpy as np\n'), ((12880, 12918), 'numpy.array_equal', 'np.array_equal', (['sample', '[False, False]'], {}), '(sample, [False, False])\n', (12894, 12918), True, 'import numpy as np\n'), ((13586, 13622), 'numpy.array_equal', 'np.array_equal', (['sample', '[True, True]'], {}), '(sample, [True, True])\n', (13600, 13622), True, 'import numpy as np\n'), ((13626, 13664), 'numpy.array_equal', 'np.array_equal', (['sample', '[False, False]'], {}), '(sample, [False, False])\n', (13640, 13664), True, 'import numpy as np\n'), ((14516, 14533), 'sympy.Symbol', 'sympy.Symbol', (['"""a"""'], {}), "('a')\n", (14528, 14533), False, 'import sympy\n'), ((16461, 16488), 'cirq.MeasurementKey', 'cirq.MeasurementKey', (['"""test"""'], {}), "('test')\n", (16480, 16488), False, 'import cirq\n'), ((12544, 12556), 'math.sqrt', 'math.sqrt', (['(2)'], {}), '(2)\n', (12553, 12556), False, 'import math\n'), ((12569, 12581), 'math.sqrt', 'math.sqrt', (['(2)'], {}), '(2)\n', (12578, 12581), False, 'import math\n'), ((13087, 13099), 'math.sqrt', 'math.sqrt', (['(2)'], {}), '(2)\n', (13096, 13099), False, 'import math\n'), ((13112, 13124), 'math.sqrt', 'math.sqrt', (['(2)'], {}), '(2)\n', (13121, 13124), False, 'import math\n'), ((13291, 13303), 'math.sqrt', 'math.sqrt', (['(2)'], {}), '(2)\n', (13300, 13303), False, 'import math\n'), ((13321, 13333), 'math.sqrt', 'math.sqrt', (['(2)'], {}), '(2)\n', (13330, 13333), False, 'import math\n')]