import pytest

import numpy as np
from casadi import MX, SX
import biorbd_casadi as biorbd
from bioptim.dynamics.configure_problem import ConfigureProblem
from bioptim.dynamics.dynamics_functions import DynamicsFunctions
from bioptim.interfaces.biorbd_interface import BiorbdInterface
from bioptim.misc.enums import ControlType
from bioptim.optimization.non_linear_program import NonLinearProgram
from bioptim.optimization.optimization_vector import OptimizationVector
from bioptim.dynamics.configure_problem import DynamicsFcn, Dynamics

from .utils import TestUtils


class OptimalControlProgram:
    def __init__(self, nlp):
        self.n_phases = 1
        self.nlp = [nlp]
        self.v = OptimizationVector(self)


@pytest.mark.parametrize("cx", [MX, SX])
@pytest.mark.parametrize("with_external_force", [False, True])
@pytest.mark.parametrize("with_contact", [False, True])
def test_torque_driven(with_contact, with_external_force, cx):
    # Prepare the program
    nlp = NonLinearProgram()
    nlp.model = biorbd.Model(
        TestUtils.bioptim_folder() + "/examples/getting_started/models/2segments_4dof_2contacts.bioMod"
    )
    nlp.ns = 5
    nlp.cx = cx

    nlp.x_bounds = np.zeros((nlp.model.nbQ() * 3, 1))
    nlp.u_bounds = np.zeros((nlp.model.nbQ(), 1))
    ocp = OptimalControlProgram(nlp)
    nlp.control_type = ControlType.CONSTANT
    NonLinearProgram.add(ocp, "dynamics_type", Dynamics(DynamicsFcn.TORQUE_DRIVEN, with_contact=with_contact), False)

    np.random.seed(42)
    if with_external_force:
        external_forces = [np.random.rand(6, nlp.model.nbSegment(), nlp.ns)]
        nlp.external_forces = BiorbdInterface.convert_array_to_external_forces(external_forces)[0]

    # Prepare the dynamics
    ConfigureProblem.initialize(ocp, nlp)

    # Test the results
    states = np.random.rand(nlp.states.shape, nlp.ns)
    controls = np.random.rand(nlp.controls.shape, nlp.ns)
    params = np.random.rand(nlp.parameters.shape, nlp.ns)
    x_out = np.array(nlp.dynamics_func(states, controls, params))

    if with_contact:
        contact_out = np.array(nlp.contact_forces_func(states, controls, params))
        if with_external_force:
            np.testing.assert_almost_equal(
                x_out[:, 0],
                [0.8631034, 0.3251833, 0.1195942, 0.4937956, -7.7700092, -7.5782306, 21.7073786, -16.3059315],
            )
            np.testing.assert_almost_equal(contact_out[:, 0], [-47.8131136, 111.1726516, -24.4449121])
        else:
            np.testing.assert_almost_equal(
                x_out[:, 0], [0.6118529, 0.785176, 0.6075449, 0.8083973, -0.3214905, -0.1912131, 0.6507164, -0.2359716]
            )
            np.testing.assert_almost_equal(contact_out[:, 0], [-2.444071, 128.8816865, 2.7245124])

    else:
        if with_external_force:
            np.testing.assert_almost_equal(
                x_out[:, 0],
                [0.86310343, 0.32518332, 0.11959425, 0.4937956, 0.30731739, -9.97912778, 1.15263778, 36.02430956],
            )
        else:
            np.testing.assert_almost_equal(
                x_out[:, 0],
                [0.61185289, 0.78517596, 0.60754485, 0.80839735, -0.30241366, -10.38503791, 1.60445173, 35.80238642],
            )


@pytest.mark.parametrize("cx", [MX, SX])
@pytest.mark.parametrize("with_external_force", [False, True])
@pytest.mark.parametrize("with_contact", [False, True])
def test_torque_derivative_driven(with_contact, with_external_force, cx):
    # Prepare the program
    nlp = NonLinearProgram()
    nlp.model = biorbd.Model(
        TestUtils.bioptim_folder() + "/examples/getting_started/models/2segments_4dof_2contacts.bioMod"
    )
    nlp.ns = 5
    nlp.cx = cx

    nlp.x_bounds = np.zeros((nlp.model.nbQ() * 3, 1))
    nlp.u_bounds = np.zeros((nlp.model.nbQ(), 1))
    ocp = OptimalControlProgram(nlp)
    nlp.control_type = ControlType.CONSTANT
    NonLinearProgram.add(
        ocp, "dynamics_type", Dynamics(DynamicsFcn.TORQUE_DERIVATIVE_DRIVEN, with_contact=with_contact), False
    )

    np.random.seed(42)
    if with_external_force:
        external_forces = [np.random.rand(6, nlp.model.nbSegment(), nlp.ns)]
        nlp.external_forces = BiorbdInterface.convert_array_to_external_forces(external_forces)[0]

    # Prepare the dynamics
    ConfigureProblem.initialize(ocp, nlp)

    # Test the results
    states = np.random.rand(nlp.states.shape, nlp.ns)
    controls = np.random.rand(nlp.controls.shape, nlp.ns)
    params = np.random.rand(nlp.parameters.shape, nlp.ns)
    x_out = np.array(nlp.dynamics_func(states, controls, params))

    if with_contact:
        contact_out = np.array(nlp.contact_forces_func(states, controls, params))
        if with_external_force:
            np.testing.assert_almost_equal(
                x_out[:, 0],
                [
                    0.8631034,
                    0.3251833,
                    0.1195942,
                    0.4937956,
                    -7.7700092,
                    -7.5782306,
                    21.7073786,
                    -16.3059315,
                    0.8074402,
                    0.4271078,
                    0.417411,
                    0.3232029,
                ],
            )
            np.testing.assert_almost_equal(contact_out[:, 0], [-47.8131136, 111.1726516, -24.4449121])
        else:
            np.testing.assert_almost_equal(
                x_out[:, 0],
                [
                    0.61185289,
                    0.78517596,
                    0.60754485,
                    0.80839735,
                    -0.32149054,
                    -0.19121314,
                    0.65071636,
                    -0.23597164,
                    0.38867729,
                    0.54269608,
                    0.77224477,
                    0.72900717,
                ],
            )
            np.testing.assert_almost_equal(contact_out[:, 0], [-2.444071, 128.8816865, 2.7245124])

    else:
        if with_external_force:
            np.testing.assert_almost_equal(
                x_out[:, 0],
                [
                    0.86310343,
                    0.32518332,
                    0.11959425,
                    0.4937956,
                    0.30731739,
                    -9.97912778,
                    1.15263778,
                    36.02430956,
                    0.80744016,
                    0.42710779,
                    0.417411,
                    0.32320293,
                ],
            )
        else:
            np.testing.assert_almost_equal(
                x_out[:, 0],
                [
                    0.61185289,
                    0.78517596,
                    0.60754485,
                    0.80839735,
                    -0.30241366,
                    -10.38503791,
                    1.60445173,
                    35.80238642,
                    0.38867729,
                    0.54269608,
                    0.77224477,
                    0.72900717,
                ],
            )


@pytest.mark.parametrize("cx", [MX, SX])
@pytest.mark.parametrize("with_external_force", [False, True])
@pytest.mark.parametrize("with_contact", [False, True])
def test_torque_activation_driven(with_contact, with_external_force, cx):
    # Prepare the program
    nlp = NonLinearProgram()
    nlp.model = biorbd.Model(
        TestUtils.bioptim_folder() + "/examples/getting_started/models/2segments_4dof_2contacts.bioMod"
    )
    nlp.ns = 5
    nlp.cx = cx
    nlp.x_bounds = np.zeros((nlp.model.nbQ() * 2, 1))
    nlp.u_bounds = np.zeros((nlp.model.nbQ(), 1))
    ocp = OptimalControlProgram(nlp)
    nlp.control_type = ControlType.CONSTANT
    NonLinearProgram.add(
        ocp, "dynamics_type", Dynamics(DynamicsFcn.TORQUE_ACTIVATIONS_DRIVEN, with_contact=with_contact), False
    )

    np.random.seed(42)
    if with_external_force:
        external_forces = [np.random.rand(6, nlp.model.nbSegment(), nlp.ns)]
        nlp.external_forces = BiorbdInterface.convert_array_to_external_forces(external_forces)[0]

    # Prepare the dynamics
    ConfigureProblem.initialize(ocp, nlp)

    # Test the results
    states = np.random.rand(nlp.states.shape, nlp.ns)
    controls = np.random.rand(nlp.controls.shape, nlp.ns)
    params = np.random.rand(nlp.parameters.shape, nlp.ns)
    x_out = np.array(nlp.dynamics_func(states, controls, params))

    if with_contact:
        contact_out = np.array(nlp.contact_forces_func(states, controls, params))
        if with_external_force:
            np.testing.assert_almost_equal(
                x_out[:, 0],
                [0.8631, 0.32518, 0.11959, 0.4938, 19.01887, 18.51503, -53.08574, 58.48719],
                decimal=5,
            )
            np.testing.assert_almost_equal(contact_out[:, 0], [109.8086936, 3790.3932439, -3571.7858574])
        else:
            np.testing.assert_almost_equal(
                x_out[:, 0],
                [0.61185289, 0.78517596, 0.60754485, 0.80839735, 0.78455384, -0.16844256, -1.56184114, 1.97658587],
                decimal=5,
            )
            np.testing.assert_almost_equal(contact_out[:, 0], [-7.88958997, 329.70828173, -263.55516549])

    else:
        if with_external_force:
            np.testing.assert_almost_equal(
                x_out[:, 0],
                [
                    8.63103426e-01,
                    3.25183322e-01,
                    1.19594246e-01,
                    4.93795596e-01,
                    1.73558072e01,
                    -4.69891264e01,
                    1.81396922e02,
                    3.61170139e03,
                ],
                decimal=5,
            )
        else:
            np.testing.assert_almost_equal(
                x_out[:, 0],
                [
                    6.11852895e-01,
                    7.85175961e-01,
                    6.07544852e-01,
                    8.08397348e-01,
                    -2.38262975e01,
                    -5.82033454e01,
                    1.27439020e02,
                    3.66531163e03,
                ],
                decimal=5,
            )


@pytest.mark.parametrize("cx", [MX, SX])
@pytest.mark.parametrize("with_external_force", [False, True])
@pytest.mark.parametrize("with_contact", [False, True])
@pytest.mark.parametrize("with_torque", [False, True])
@pytest.mark.parametrize("with_excitations", [False, True])
def test_muscle_driven(with_excitations, with_contact, with_torque, with_external_force, cx):
    # Prepare the program
    nlp = NonLinearProgram()
    nlp.model = biorbd.Model(
        TestUtils.bioptim_folder() + "/examples/muscle_driven_ocp/models/arm26_with_contact.bioMod"
    )
    nlp.ns = 5
    nlp.cx = cx

    nlp.x_bounds = np.zeros((nlp.model.nbQ() * 2 + nlp.model.nbMuscles(), 1))
    nlp.u_bounds = np.zeros((nlp.model.nbMuscles(), 1))
    ocp = OptimalControlProgram(nlp)
    nlp.control_type = ControlType.CONSTANT
    NonLinearProgram.add(
        ocp,
        "dynamics_type",
        Dynamics(
            DynamicsFcn.MUSCLE_DRIVEN,
            with_torque=with_torque,
            with_excitations=with_excitations,
            with_contact=with_contact,
        ),
        False,
    )

    np.random.seed(42)
    if with_external_force:
        external_forces = [np.random.rand(6, nlp.model.nbSegment(), nlp.ns)]
        nlp.external_forces = BiorbdInterface.convert_array_to_external_forces(external_forces)[0]

    # Prepare the dynamics
    ConfigureProblem.initialize(ocp, nlp)

    # Test the results
    states = np.random.rand(nlp.states.shape, nlp.ns)
    controls = np.random.rand(nlp.controls.shape, nlp.ns)
    params = np.random.rand(nlp.parameters.shape, nlp.ns)
    x_out = np.array(nlp.dynamics_func(states, controls, params))

    if with_contact:  # Warning this test is a bit bogus, there since the model does not have contacts
        if with_torque:
            if with_excitations:
                if with_external_force:
                    np.testing.assert_almost_equal(
                        x_out[:, 0],
                        [
                            0.6158501,
                            0.50313626,
                            0.64241928,
                            1.07179622,
                            -33.76217857,
                            36.21815923,
                            46.87928022,
                            -1.80189035,
                            53.3914525,
                            48.30056919,
                            63.69373374,
                            -28.15700995,
                        ],
                    )
                else:
                    np.testing.assert_almost_equal(
                        x_out[:, 0],
                        [
                            1.83404510e-01,
                            6.11852895e-01,
                            7.85175961e-01,
                            -9.29662878e00,
                            3.00872062e02,
                            -9.50354903e02,
                            8.60630831e00,
                            3.19433638e00,
                            2.97405608e01,
                            -2.02754226e01,
                            -2.32467778e01,
                            -4.19135012e01,
                        ],
                        decimal=6,
                    )
            else:
                if with_external_force:
                    np.testing.assert_almost_equal(
                        x_out[:, 0],
                        [6.15850098e-01, 5.03136259e-01, 6.42419278e-01, -8.06478367e00, 2.42279101e02, -7.72114103e02],
                        decimal=6,
                    )
                else:
                    np.testing.assert_almost_equal(
                        x_out[:, 0],
                        [1.83404510e-01, 6.11852895e-01, 7.85175961e-01, -3.80892207e00, 1.20476051e02, -4.33291346e02],
                        decimal=6,
                    )

        else:
            if with_excitations:
                if with_external_force:
                    np.testing.assert_almost_equal(
                        x_out[:, 0],
                        [
                            0.6158501,
                            0.50313626,
                            0.64241928,
                            0.91952705,
                            -39.04876174,
                            45.31837288,
                            55.65557816,
                            50.47052688,
                            0.36025589,
                            58.92377491,
                            29.70094194,
                            -15.13534937,
                        ],
                    )
                else:
                    np.testing.assert_almost_equal(
                        x_out[:, 0],
                        [
                            1.83404510e-01,
                            6.11852895e-01,
                            7.85175961e-01,
                            -9.72712350e00,
                            3.10866170e02,
                            -9.82725656e02,
                            -7.72228930e00,
                            -1.13759732e01,
                            9.51906209e01,
                            4.45077128e00,
                            -5.20261014e00,
                            -2.80864106e01,
                        ],
                        decimal=6,
                    )
            else:
                if with_external_force:
                    np.testing.assert_almost_equal(
                        x_out[:, 0],
                        [0.6158501, 0.50313626, 0.64241928, 0.91952705, -39.04876174, 45.31837288],
                    )
                else:
                    np.testing.assert_almost_equal(
                        x_out[:, 0],
                        [1.83404510e-01, 6.11852895e-01, 7.85175961e-01, -9.72712350e00, 3.10866170e02, -9.82725656e02],
                        decimal=6,
                    )

    else:
        if with_torque:
            if with_excitations:
                if with_external_force:
                    np.testing.assert_almost_equal(
                        x_out[:, 0],
                        [
                            0.6158501,
                            0.50313626,
                            0.64241928,
                            1.07179622,
                            -33.76217857,
                            36.21815923,
                            46.87928022,
                            -1.80189035,
                            53.3914525,
                            48.30056919,
                            63.69373374,
                            -28.15700995,
                        ],
                    )
                else:
                    np.testing.assert_almost_equal(
                        x_out[:, 0],
                        [
                            1.83404510e-01,
                            6.11852895e-01,
                            7.85175961e-01,
                            -9.29662878e00,
                            3.00872062e02,
                            -9.50354903e02,
                            8.60630831e00,
                            3.19433638e00,
                            2.97405608e01,
                            -2.02754226e01,
                            -2.32467778e01,
                            -4.19135012e01,
                        ],
                        decimal=6,
                    )
            else:
                if with_external_force:
                    np.testing.assert_almost_equal(
                        x_out[:, 0],
                        [6.15850098e-01, 5.03136259e-01, 6.42419278e-01, -8.06478367e00, 2.42279101e02, -7.72114103e02],
                        decimal=6,
                    )
                else:
                    np.testing.assert_almost_equal(
                        x_out[:, 0],
                        [1.83404510e-01, 6.11852895e-01, 7.85175961e-01, -3.80892207e00, 1.20476051e02, -4.33291346e02],
                        decimal=6,
                    )

        else:
            if with_excitations:
                if with_external_force:
                    np.testing.assert_almost_equal(
                        x_out[:, 0],
                        [
                            0.6158501,
                            0.50313626,
                            0.64241928,
                            0.91952705,
                            -39.04876174,
                            45.31837288,
                            55.65557816,
                            50.47052688,
                            0.36025589,
                            58.92377491,
                            29.70094194,
                            -15.13534937,
                        ],
                    )
                else:
                    np.testing.assert_almost_equal(
                        x_out[:, 0],
                        [
                            1.83404510e-01,
                            6.11852895e-01,
                            7.85175961e-01,
                            -9.72712350e00,
                            3.10866170e02,
                            -9.82725656e02,
                            -7.72228930e00,
                            -1.13759732e01,
                            9.51906209e01,
                            4.45077128e00,
                            -5.20261014e00,
                            -2.80864106e01,
                        ],
                        decimal=6,
                    )
            else:
                if with_external_force:
                    np.testing.assert_almost_equal(
                        x_out[:, 0],
                        [0.6158501, 0.50313626, 0.64241928, 0.91952705, -39.04876174, 45.31837288],
                    )
                else:
                    np.testing.assert_almost_equal(
                        x_out[:, 0],
                        [1.83404510e-01, 6.11852895e-01, 7.85175961e-01, -9.72712350e00, 3.10866170e02, -9.82725656e02],
                        decimal=6,
                    )


@pytest.mark.parametrize("with_contact", [False, True])
def test_custom_dynamics(with_contact):
    def custom_dynamic(states, controls, parameters, nlp, with_contact=False) -> tuple:
        DynamicsFunctions.apply_parameters(parameters, nlp)
        q = DynamicsFunctions.get(nlp.states["q"], states)
        qdot = DynamicsFunctions.get(nlp.states["qdot"], states)
        tau = DynamicsFunctions.get(nlp.controls["tau"], controls)

        dq = DynamicsFunctions.compute_qdot(nlp, q, qdot)
        ddq = DynamicsFunctions.forward_dynamics(nlp, q, qdot, tau, with_contact)

        return dq, ddq

    def configure(ocp, nlp, with_contact=None):
        ConfigureProblem.configure_q(nlp, True, False)
        ConfigureProblem.configure_qdot(nlp, True, False)
        ConfigureProblem.configure_tau(nlp, False, True)
        ConfigureProblem.configure_dynamics_function(ocp, nlp, custom_dynamic, with_contact=with_contact)

        if with_contact:
            ConfigureProblem.configure_contact_function(ocp, nlp, DynamicsFunctions.forces_from_torque_driven)

    # Prepare the program
    nlp = NonLinearProgram()
    nlp.model = biorbd.Model(
        TestUtils.bioptim_folder() + "/examples/getting_started/models/2segments_4dof_2contacts.bioMod"
    )
    nlp.ns = 5
    nlp.cx = MX

    nlp.x_bounds = np.zeros((nlp.model.nbQ() * 3, 1))
    nlp.u_bounds = np.zeros((nlp.model.nbQ(), 1))
    ocp = OptimalControlProgram(nlp)
    nlp.control_type = ControlType.CONSTANT
    NonLinearProgram.add(
        ocp, "dynamics_type", Dynamics(configure, dynamic_function=custom_dynamic, with_contact=with_contact), False
    )

    np.random.seed(42)

    # Prepare the dynamics
    ConfigureProblem.initialize(ocp, nlp)

    # Test the results
    states = np.random.rand(nlp.states.shape, nlp.ns)
    controls = np.random.rand(nlp.controls.shape, nlp.ns)
    params = np.random.rand(nlp.parameters.shape, nlp.ns)
    x_out = np.array(nlp.dynamics_func(states, controls, params))

    if with_contact:
        contact_out = np.array(nlp.contact_forces_func(states, controls, params))
        np.testing.assert_almost_equal(
            x_out[:, 0], [0.6118529, 0.785176, 0.6075449, 0.8083973, -0.3214905, -0.1912131, 0.6507164, -0.2359716]
        )
        np.testing.assert_almost_equal(contact_out[:, 0], [-2.444071, 128.8816865, 2.7245124])

    else:
        np.testing.assert_almost_equal(
            x_out[:, 0],
            [0.61185289, 0.78517596, 0.60754485, 0.80839735, -0.30241366, -10.38503791, 1.60445173, 35.80238642],
        )

[((724, 763), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""cx"""', '[MX, SX]'], {}), "('cx', [MX, SX])\n", (747, 763), False, 'import pytest\n'), ((765, 826), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""with_external_force"""', '[False, True]'], {}), "('with_external_force', [False, True])\n", (788, 826), False, 'import pytest\n'), ((828, 882), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""with_contact"""', '[False, True]'], {}), "('with_contact', [False, True])\n", (851, 882), False, 'import pytest\n'), ((3229, 3268), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""cx"""', '[MX, SX]'], {}), "('cx', [MX, SX])\n", (3252, 3268), False, 'import pytest\n'), ((3270, 3331), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""with_external_force"""', '[False, True]'], {}), "('with_external_force', [False, True])\n", (3293, 3331), False, 'import pytest\n'), ((3333, 3387), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""with_contact"""', '[False, True]'], {}), "('with_contact', [False, True])\n", (3356, 3387), False, 'import pytest\n'), ((7017, 7056), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""cx"""', '[MX, SX]'], {}), "('cx', [MX, SX])\n", (7040, 7056), False, 'import pytest\n'), ((7058, 7119), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""with_external_force"""', '[False, True]'], {}), "('with_external_force', [False, True])\n", (7081, 7119), False, 'import pytest\n'), ((7121, 7175), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""with_contact"""', '[False, True]'], {}), "('with_contact', [False, True])\n", (7144, 7175), False, 'import pytest\n'), ((10095, 10134), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""cx"""', '[MX, SX]'], {}), "('cx', [MX, SX])\n", (10118, 10134), False, 'import pytest\n'), ((10136, 10197), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""with_external_force"""', '[False, True]'], {}), "('with_external_force', [False, True])\n", (10159, 10197), False, 'import pytest\n'), ((10199, 10253), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""with_contact"""', '[False, True]'], {}), "('with_contact', [False, True])\n", (10222, 10253), False, 'import pytest\n'), ((10255, 10308), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""with_torque"""', '[False, True]'], {}), "('with_torque', [False, True])\n", (10278, 10308), False, 'import pytest\n'), ((10310, 10368), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""with_excitations"""', '[False, True]'], {}), "('with_excitations', [False, True])\n", (10333, 10368), False, 'import pytest\n'), ((20157, 20211), 'pytest.mark.parametrize', 'pytest.mark.parametrize', (['"""with_contact"""', '[False, True]'], {}), "('with_contact', [False, True])\n", (20180, 20211), False, 'import pytest\n'), ((982, 1000), 'bioptim.optimization.non_linear_program.NonLinearProgram', 'NonLinearProgram', ([], {}), '()\n', (998, 1000), False, 'from bioptim.optimization.non_linear_program import NonLinearProgram\n'), ((1481, 1499), 'numpy.random.seed', 'np.random.seed', (['(42)'], {}), '(42)\n', (1495, 1499), True, 'import numpy as np\n'), ((1736, 1773), 'bioptim.dynamics.configure_problem.ConfigureProblem.initialize', 'ConfigureProblem.initialize', (['ocp', 'nlp'], {}), '(ocp, nlp)\n', (1763, 1773), False, 'from bioptim.dynamics.configure_problem import ConfigureProblem\n'), ((1811, 1851), 'numpy.random.rand', 'np.random.rand', (['nlp.states.shape', 'nlp.ns'], {}), '(nlp.states.shape, nlp.ns)\n', (1825, 1851), True, 'import numpy as np\n'), ((1867, 1909), 'numpy.random.rand', 'np.random.rand', (['nlp.controls.shape', 'nlp.ns'], {}), '(nlp.controls.shape, nlp.ns)\n', (1881, 1909), True, 'import numpy as np\n'), ((1923, 1967), 'numpy.random.rand', 'np.random.rand', (['nlp.parameters.shape', 'nlp.ns'], {}), '(nlp.parameters.shape, nlp.ns)\n', (1937, 1967), True, 'import numpy as np\n'), ((3498, 3516), 'bioptim.optimization.non_linear_program.NonLinearProgram', 'NonLinearProgram', ([], {}), '()\n', (3514, 3516), False, 'from bioptim.optimization.non_linear_program import NonLinearProgram\n'), ((4022, 4040), 'numpy.random.seed', 'np.random.seed', (['(42)'], {}), '(42)\n', (4036, 4040), True, 'import numpy as np\n'), ((4277, 4314), 'bioptim.dynamics.configure_problem.ConfigureProblem.initialize', 'ConfigureProblem.initialize', (['ocp', 'nlp'], {}), '(ocp, nlp)\n', (4304, 4314), False, 'from bioptim.dynamics.configure_problem import ConfigureProblem\n'), ((4352, 4392), 'numpy.random.rand', 'np.random.rand', (['nlp.states.shape', 'nlp.ns'], {}), '(nlp.states.shape, nlp.ns)\n', (4366, 4392), True, 'import numpy as np\n'), ((4408, 4450), 'numpy.random.rand', 'np.random.rand', (['nlp.controls.shape', 'nlp.ns'], {}), '(nlp.controls.shape, nlp.ns)\n', (4422, 4450), True, 'import numpy as np\n'), ((4464, 4508), 'numpy.random.rand', 'np.random.rand', (['nlp.parameters.shape', 'nlp.ns'], {}), '(nlp.parameters.shape, nlp.ns)\n', (4478, 4508), True, 'import numpy as np\n'), ((7286, 7304), 'bioptim.optimization.non_linear_program.NonLinearProgram', 'NonLinearProgram', ([], {}), '()\n', (7302, 7304), False, 'from bioptim.optimization.non_linear_program import NonLinearProgram\n'), ((7810, 7828), 'numpy.random.seed', 'np.random.seed', (['(42)'], {}), '(42)\n', (7824, 7828), True, 'import numpy as np\n'), ((8065, 8102), 'bioptim.dynamics.configure_problem.ConfigureProblem.initialize', 'ConfigureProblem.initialize', (['ocp', 'nlp'], {}), '(ocp, nlp)\n', (8092, 8102), False, 'from bioptim.dynamics.configure_problem import ConfigureProblem\n'), ((8140, 8180), 'numpy.random.rand', 'np.random.rand', (['nlp.states.shape', 'nlp.ns'], {}), '(nlp.states.shape, nlp.ns)\n', (8154, 8180), True, 'import numpy as np\n'), ((8196, 8238), 'numpy.random.rand', 'np.random.rand', (['nlp.controls.shape', 'nlp.ns'], {}), '(nlp.controls.shape, nlp.ns)\n', (8210, 8238), True, 'import numpy as np\n'), ((8252, 8296), 'numpy.random.rand', 'np.random.rand', (['nlp.parameters.shape', 'nlp.ns'], {}), '(nlp.parameters.shape, nlp.ns)\n', (8266, 8296), True, 'import numpy as np\n'), ((10499, 10517), 'bioptim.optimization.non_linear_program.NonLinearProgram', 'NonLinearProgram', ([], {}), '()\n', (10515, 10517), False, 'from bioptim.optimization.non_linear_program import NonLinearProgram\n'), ((11182, 11200), 'numpy.random.seed', 'np.random.seed', (['(42)'], {}), '(42)\n', (11196, 11200), True, 'import numpy as np\n'), ((11437, 11474), 'bioptim.dynamics.configure_problem.ConfigureProblem.initialize', 'ConfigureProblem.initialize', (['ocp', 'nlp'], {}), '(ocp, nlp)\n', (11464, 11474), False, 'from bioptim.dynamics.configure_problem import ConfigureProblem\n'), ((11512, 11552), 'numpy.random.rand', 'np.random.rand', (['nlp.states.shape', 'nlp.ns'], {}), '(nlp.states.shape, nlp.ns)\n', (11526, 11552), True, 'import numpy as np\n'), ((11568, 11610), 'numpy.random.rand', 'np.random.rand', (['nlp.controls.shape', 'nlp.ns'], {}), '(nlp.controls.shape, nlp.ns)\n', (11582, 11610), True, 'import numpy as np\n'), ((11624, 11668), 'numpy.random.rand', 'np.random.rand', (['nlp.parameters.shape', 'nlp.ns'], {}), '(nlp.parameters.shape, nlp.ns)\n', (11638, 11668), True, 'import numpy as np\n'), ((21255, 21273), 'bioptim.optimization.non_linear_program.NonLinearProgram', 'NonLinearProgram', ([], {}), '()\n', (21271, 21273), False, 'from bioptim.optimization.non_linear_program import NonLinearProgram\n'), ((21785, 21803), 'numpy.random.seed', 'np.random.seed', (['(42)'], {}), '(42)\n', (21799, 21803), True, 'import numpy as np\n'), ((21836, 21873), 'bioptim.dynamics.configure_problem.ConfigureProblem.initialize', 'ConfigureProblem.initialize', (['ocp', 'nlp'], {}), '(ocp, nlp)\n', (21863, 21873), False, 'from bioptim.dynamics.configure_problem import ConfigureProblem\n'), ((21911, 21951), 'numpy.random.rand', 'np.random.rand', (['nlp.states.shape', 'nlp.ns'], {}), '(nlp.states.shape, nlp.ns)\n', (21925, 21951), True, 'import numpy as np\n'), ((21967, 22009), 'numpy.random.rand', 'np.random.rand', (['nlp.controls.shape', 'nlp.ns'], {}), '(nlp.controls.shape, nlp.ns)\n', (21981, 22009), True, 'import numpy as np\n'), ((22023, 22067), 'numpy.random.rand', 'np.random.rand', (['nlp.parameters.shape', 'nlp.ns'], {}), '(nlp.parameters.shape, nlp.ns)\n', (22037, 22067), True, 'import numpy as np\n'), ((696, 720), 'bioptim.optimization.optimization_vector.OptimizationVector', 'OptimizationVector', (['self'], {}), '(self)\n', (714, 720), False, 'from bioptim.optimization.optimization_vector import OptimizationVector\n'), ((1405, 1467), 'bioptim.dynamics.configure_problem.Dynamics', 'Dynamics', (['DynamicsFcn.TORQUE_DRIVEN'], {'with_contact': 'with_contact'}), '(DynamicsFcn.TORQUE_DRIVEN, with_contact=with_contact)\n', (1413, 1467), False, 'from bioptim.dynamics.configure_problem import DynamicsFcn, Dynamics\n'), ((3930, 4003), 'bioptim.dynamics.configure_problem.Dynamics', 'Dynamics', (['DynamicsFcn.TORQUE_DERIVATIVE_DRIVEN'], {'with_contact': 'with_contact'}), '(DynamicsFcn.TORQUE_DERIVATIVE_DRIVEN, with_contact=with_contact)\n', (3938, 4003), False, 'from bioptim.dynamics.configure_problem import DynamicsFcn, Dynamics\n'), ((7717, 7791), 'bioptim.dynamics.configure_problem.Dynamics', 'Dynamics', (['DynamicsFcn.TORQUE_ACTIVATIONS_DRIVEN'], {'with_contact': 'with_contact'}), '(DynamicsFcn.TORQUE_ACTIVATIONS_DRIVEN, with_contact=with_contact)\n', (7725, 7791), False, 'from bioptim.dynamics.configure_problem import DynamicsFcn, Dynamics\n'), ((10973, 11099), 'bioptim.dynamics.configure_problem.Dynamics', 'Dynamics', (['DynamicsFcn.MUSCLE_DRIVEN'], {'with_torque': 'with_torque', 'with_excitations': 'with_excitations', 'with_contact': 'with_contact'}), '(DynamicsFcn.MUSCLE_DRIVEN, with_torque=with_torque,\n    with_excitations=with_excitations, with_contact=with_contact)\n', (10981, 11099), False, 'from bioptim.dynamics.configure_problem import DynamicsFcn, Dynamics\n'), ((20348, 20399), 'bioptim.dynamics.dynamics_functions.DynamicsFunctions.apply_parameters', 'DynamicsFunctions.apply_parameters', (['parameters', 'nlp'], {}), '(parameters, nlp)\n', (20382, 20399), False, 'from bioptim.dynamics.dynamics_functions import DynamicsFunctions\n'), ((20412, 20458), 'bioptim.dynamics.dynamics_functions.DynamicsFunctions.get', 'DynamicsFunctions.get', (["nlp.states['q']", 'states'], {}), "(nlp.states['q'], states)\n", (20433, 20458), False, 'from bioptim.dynamics.dynamics_functions import DynamicsFunctions\n'), ((20474, 20523), 'bioptim.dynamics.dynamics_functions.DynamicsFunctions.get', 'DynamicsFunctions.get', (["nlp.states['qdot']", 'states'], {}), "(nlp.states['qdot'], states)\n", (20495, 20523), False, 'from bioptim.dynamics.dynamics_functions import DynamicsFunctions\n'), ((20538, 20590), 'bioptim.dynamics.dynamics_functions.DynamicsFunctions.get', 'DynamicsFunctions.get', (["nlp.controls['tau']", 'controls'], {}), "(nlp.controls['tau'], controls)\n", (20559, 20590), False, 'from bioptim.dynamics.dynamics_functions import DynamicsFunctions\n'), ((20605, 20649), 'bioptim.dynamics.dynamics_functions.DynamicsFunctions.compute_qdot', 'DynamicsFunctions.compute_qdot', (['nlp', 'q', 'qdot'], {}), '(nlp, q, qdot)\n', (20635, 20649), False, 'from bioptim.dynamics.dynamics_functions import DynamicsFunctions\n'), ((20664, 20731), 'bioptim.dynamics.dynamics_functions.DynamicsFunctions.forward_dynamics', 'DynamicsFunctions.forward_dynamics', (['nlp', 'q', 'qdot', 'tau', 'with_contact'], {}), '(nlp, q, qdot, tau, with_contact)\n', (20698, 20731), False, 'from bioptim.dynamics.dynamics_functions import DynamicsFunctions\n'), ((20813, 20859), 'bioptim.dynamics.configure_problem.ConfigureProblem.configure_q', 'ConfigureProblem.configure_q', (['nlp', '(True)', '(False)'], {}), '(nlp, True, False)\n', (20841, 20859), False, 'from bioptim.dynamics.configure_problem import ConfigureProblem\n'), ((20868, 20917), 'bioptim.dynamics.configure_problem.ConfigureProblem.configure_qdot', 'ConfigureProblem.configure_qdot', (['nlp', '(True)', '(False)'], {}), '(nlp, True, False)\n', (20899, 20917), False, 'from bioptim.dynamics.configure_problem import ConfigureProblem\n'), ((20926, 20974), 'bioptim.dynamics.configure_problem.ConfigureProblem.configure_tau', 'ConfigureProblem.configure_tau', (['nlp', '(False)', '(True)'], {}), '(nlp, False, True)\n', (20956, 20974), False, 'from bioptim.dynamics.configure_problem import ConfigureProblem\n'), ((20983, 21084), 'bioptim.dynamics.configure_problem.ConfigureProblem.configure_dynamics_function', 'ConfigureProblem.configure_dynamics_function', (['ocp', 'nlp', 'custom_dynamic'], {'with_contact': 'with_contact'}), '(ocp, nlp, custom_dynamic,\n    with_contact=with_contact)\n', (21027, 21084), False, 'from bioptim.dynamics.configure_problem import ConfigureProblem\n'), ((21687, 21766), 'bioptim.dynamics.configure_problem.Dynamics', 'Dynamics', (['configure'], {'dynamic_function': 'custom_dynamic', 'with_contact': 'with_contact'}), '(configure, dynamic_function=custom_dynamic, with_contact=with_contact)\n', (21695, 21766), False, 'from bioptim.dynamics.configure_problem import DynamicsFcn, Dynamics\n'), ((22246, 22388), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.6118529, 0.785176, 0.6075449, 0.8083973, -0.3214905, -0.1912131, \n    0.6507164, -0.2359716]'], {}), '(x_out[:, (0)], [0.6118529, 0.785176, \n    0.6075449, 0.8083973, -0.3214905, -0.1912131, 0.6507164, -0.2359716])\n', (22276, 22388), True, 'import numpy as np\n'), ((22412, 22504), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['contact_out[:, (0)]', '[-2.444071, 128.8816865, 2.7245124]'], {}), '(contact_out[:, (0)], [-2.444071, 128.8816865,\n    2.7245124])\n', (22442, 22504), True, 'import numpy as np\n'), ((22518, 22675), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.61185289, 0.78517596, 0.60754485, 0.80839735, -0.30241366, -10.38503791,\n    1.60445173, 35.80238642]'], {}), '(x_out[:, (0)], [0.61185289, 0.78517596, \n    0.60754485, 0.80839735, -0.30241366, -10.38503791, 1.60445173, 35.80238642]\n    )\n', (22548, 22675), True, 'import numpy as np\n'), ((1635, 1700), 'bioptim.interfaces.biorbd_interface.BiorbdInterface.convert_array_to_external_forces', 'BiorbdInterface.convert_array_to_external_forces', (['external_forces'], {}), '(external_forces)\n', (1683, 1700), False, 'from bioptim.interfaces.biorbd_interface import BiorbdInterface\n'), ((2182, 2327), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.8631034, 0.3251833, 0.1195942, 0.4937956, -7.7700092, -7.5782306, \n    21.7073786, -16.3059315]'], {}), '(x_out[:, (0)], [0.8631034, 0.3251833, \n    0.1195942, 0.4937956, -7.7700092, -7.5782306, 21.7073786, -16.3059315])\n', (2212, 2327), True, 'import numpy as np\n'), ((2380, 2477), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['contact_out[:, (0)]', '[-47.8131136, 111.1726516, -24.4449121]'], {}), '(contact_out[:, (0)], [-47.8131136, \n    111.1726516, -24.4449121])\n', (2410, 2477), True, 'import numpy as np\n'), ((2497, 2639), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.6118529, 0.785176, 0.6075449, 0.8083973, -0.3214905, -0.1912131, \n    0.6507164, -0.2359716]'], {}), '(x_out[:, (0)], [0.6118529, 0.785176, \n    0.6075449, 0.8083973, -0.3214905, -0.1912131, 0.6507164, -0.2359716])\n', (2527, 2639), True, 'import numpy as np\n'), ((2675, 2767), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['contact_out[:, (0)]', '[-2.444071, 128.8816865, 2.7245124]'], {}), '(contact_out[:, (0)], [-2.444071, 128.8816865,\n    2.7245124])\n', (2705, 2767), True, 'import numpy as np\n'), ((2817, 2966), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.86310343, 0.32518332, 0.11959425, 0.4937956, 0.30731739, -9.97912778, \n    1.15263778, 36.02430956]'], {}), '(x_out[:, (0)], [0.86310343, 0.32518332, \n    0.11959425, 0.4937956, 0.30731739, -9.97912778, 1.15263778, 36.02430956])\n', (2847, 2966), True, 'import numpy as np\n'), ((3033, 3190), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.61185289, 0.78517596, 0.60754485, 0.80839735, -0.30241366, -10.38503791,\n    1.60445173, 35.80238642]'], {}), '(x_out[:, (0)], [0.61185289, 0.78517596, \n    0.60754485, 0.80839735, -0.30241366, -10.38503791, 1.60445173, 35.80238642]\n    )\n', (3063, 3190), True, 'import numpy as np\n'), ((4176, 4241), 'bioptim.interfaces.biorbd_interface.BiorbdInterface.convert_array_to_external_forces', 'BiorbdInterface.convert_array_to_external_forces', (['external_forces'], {}), '(external_forces)\n', (4224, 4241), False, 'from bioptim.interfaces.biorbd_interface import BiorbdInterface\n'), ((4723, 4916), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.8631034, 0.3251833, 0.1195942, 0.4937956, -7.7700092, -7.5782306, \n    21.7073786, -16.3059315, 0.8074402, 0.4271078, 0.417411, 0.3232029]'], {}), '(x_out[:, (0)], [0.8631034, 0.3251833, \n    0.1195942, 0.4937956, -7.7700092, -7.5782306, 21.7073786, -16.3059315, \n    0.8074402, 0.4271078, 0.417411, 0.3232029])\n', (4753, 4916), True, 'import numpy as np\n'), ((5223, 5320), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['contact_out[:, (0)]', '[-47.8131136, 111.1726516, -24.4449121]'], {}), '(contact_out[:, (0)], [-47.8131136, \n    111.1726516, -24.4449121])\n', (5253, 5320), True, 'import numpy as np\n'), ((5340, 5544), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.61185289, 0.78517596, 0.60754485, 0.80839735, -0.32149054, -0.19121314, \n    0.65071636, -0.23597164, 0.38867729, 0.54269608, 0.77224477, 0.72900717]'], {}), '(x_out[:, (0)], [0.61185289, 0.78517596, \n    0.60754485, 0.80839735, -0.32149054, -0.19121314, 0.65071636, -\n    0.23597164, 0.38867729, 0.54269608, 0.77224477, 0.72900717])\n', (5370, 5544), True, 'import numpy as np\n'), ((5851, 5943), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['contact_out[:, (0)]', '[-2.444071, 128.8816865, 2.7245124]'], {}), '(contact_out[:, (0)], [-2.444071, 128.8816865,\n    2.7245124])\n', (5881, 5943), True, 'import numpy as np\n'), ((5993, 6192), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.86310343, 0.32518332, 0.11959425, 0.4937956, 0.30731739, -9.97912778, \n    1.15263778, 36.02430956, 0.80744016, 0.42710779, 0.417411, 0.32320293]'], {}), '(x_out[:, (0)], [0.86310343, 0.32518332, \n    0.11959425, 0.4937956, 0.30731739, -9.97912778, 1.15263778, 36.02430956,\n    0.80744016, 0.42710779, 0.417411, 0.32320293])\n', (6023, 6192), True, 'import numpy as np\n'), ((6514, 6719), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.61185289, 0.78517596, 0.60754485, 0.80839735, -0.30241366, -10.38503791,\n    1.60445173, 35.80238642, 0.38867729, 0.54269608, 0.77224477, 0.72900717]'], {}), '(x_out[:, (0)], [0.61185289, 0.78517596, \n    0.60754485, 0.80839735, -0.30241366, -10.38503791, 1.60445173, \n    35.80238642, 0.38867729, 0.54269608, 0.77224477, 0.72900717])\n', (6544, 6719), True, 'import numpy as np\n'), ((7964, 8029), 'bioptim.interfaces.biorbd_interface.BiorbdInterface.convert_array_to_external_forces', 'BiorbdInterface.convert_array_to_external_forces', (['external_forces'], {}), '(external_forces)\n', (8012, 8029), False, 'from bioptim.interfaces.biorbd_interface import BiorbdInterface\n'), ((8511, 8649), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.8631, 0.32518, 0.11959, 0.4938, 19.01887, 18.51503, -53.08574, 58.48719]'], {'decimal': '(5)'}), '(x_out[:, (0)], [0.8631, 0.32518, 0.11959, \n    0.4938, 19.01887, 18.51503, -53.08574, 58.48719], decimal=5)\n', (8541, 8649), True, 'import numpy as np\n'), ((8718, 8818), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['contact_out[:, (0)]', '[109.8086936, 3790.3932439, -3571.7858574]'], {}), '(contact_out[:, (0)], [109.8086936, \n    3790.3932439, -3571.7858574])\n', (8748, 8818), True, 'import numpy as np\n'), ((8838, 9004), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.61185289, 0.78517596, 0.60754485, 0.80839735, 0.78455384, -0.16844256, -\n    1.56184114, 1.97658587]'], {'decimal': '(5)'}), '(x_out[:, (0)], [0.61185289, 0.78517596, \n    0.60754485, 0.80839735, 0.78455384, -0.16844256, -1.56184114, \n    1.97658587], decimal=5)\n', (8868, 9004), True, 'import numpy as np\n'), ((9068, 9168), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['contact_out[:, (0)]', '[-7.88958997, 329.70828173, -263.55516549]'], {}), '(contact_out[:, (0)], [-7.88958997, \n    329.70828173, -263.55516549])\n', (9098, 9168), True, 'import numpy as np\n'), ((9217, 9386), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.863103426, 0.325183322, 0.119594246, 0.493795596, 17.3558072, -\n    46.9891264, 181.396922, 3611.70139]'], {'decimal': '(5)'}), '(x_out[:, (0)], [0.863103426, 0.325183322, \n    0.119594246, 0.493795596, 17.3558072, -46.9891264, 181.396922, \n    3611.70139], decimal=5)\n', (9247, 9386), True, 'import numpy as np\n'), ((9667, 9836), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.611852895, 0.785175961, 0.607544852, 0.808397348, -23.8262975, -\n    58.2033454, 127.43902, 3665.31163]'], {'decimal': '(5)'}), '(x_out[:, (0)], [0.611852895, 0.785175961, \n    0.607544852, 0.808397348, -23.8262975, -58.2033454, 127.43902, \n    3665.31163], decimal=5)\n', (9697, 9836), True, 'import numpy as np\n'), ((11336, 11401), 'bioptim.interfaces.biorbd_interface.BiorbdInterface.convert_array_to_external_forces', 'BiorbdInterface.convert_array_to_external_forces', (['external_forces'], {}), '(external_forces)\n', (11384, 11401), False, 'from bioptim.interfaces.biorbd_interface import BiorbdInterface\n'), ((21119, 21222), 'bioptim.dynamics.configure_problem.ConfigureProblem.configure_contact_function', 'ConfigureProblem.configure_contact_function', (['ocp', 'nlp', 'DynamicsFunctions.forces_from_torque_driven'], {}), '(ocp, nlp, DynamicsFunctions.\n    forces_from_torque_driven)\n', (21162, 21222), False, 'from bioptim.dynamics.configure_problem import ConfigureProblem\n'), ((11956, 12165), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.6158501, 0.50313626, 0.64241928, 1.07179622, -33.76217857, 36.21815923, \n    46.87928022, -1.80189035, 53.3914525, 48.30056919, 63.69373374, -\n    28.15700995]'], {}), '(x_out[:, (0)], [0.6158501, 0.50313626, \n    0.64241928, 1.07179622, -33.76217857, 36.21815923, 46.87928022, -\n    1.80189035, 53.3914525, 48.30056919, 63.69373374, -28.15700995])\n', (11986, 12165), True, 'import numpy as np\n'), ((12630, 12849), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.18340451, 0.611852895, 0.785175961, -9.29662878, 300.872062, -950.354903,\n    8.60630831, 3.19433638, 29.7405608, -20.2754226, -23.2467778, -41.9135012]'], {'decimal': '(6)'}), '(x_out[:, (0)], [0.18340451, 0.611852895, \n    0.785175961, -9.29662878, 300.872062, -950.354903, 8.60630831, \n    3.19433638, 29.7405608, -20.2754226, -23.2467778, -41.9135012], decimal=6)\n', (12660, 12849), True, 'import numpy as np\n'), ((13411, 13551), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.615850098, 0.503136259, 0.642419278, -8.06478367, 242.279101, -772.114103]'], {'decimal': '(6)'}), '(x_out[:, (0)], [0.615850098, 0.503136259, \n    0.642419278, -8.06478367, 242.279101, -772.114103], decimal=6)\n', (13441, 13551), True, 'import numpy as np\n'), ((13700, 13839), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.18340451, 0.611852895, 0.785175961, -3.80892207, 120.476051, -433.291346]'], {'decimal': '(6)'}), '(x_out[:, (0)], [0.18340451, 0.611852895, \n    0.785175961, -3.80892207, 120.476051, -433.291346], decimal=6)\n', (13730, 13839), True, 'import numpy as np\n'), ((14055, 14264), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.6158501, 0.50313626, 0.64241928, 0.91952705, -39.04876174, 45.31837288, \n    55.65557816, 50.47052688, 0.36025589, 58.92377491, 29.70094194, -\n    15.13534937]'], {}), '(x_out[:, (0)], [0.6158501, 0.50313626, \n    0.64241928, 0.91952705, -39.04876174, 45.31837288, 55.65557816, \n    50.47052688, 0.36025589, 58.92377491, 29.70094194, -15.13534937])\n', (14085, 14264), True, 'import numpy as np\n'), ((14729, 14946), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.18340451, 0.611852895, 0.785175961, -9.7271235, 310.86617, -982.725656, \n    -7.7222893, -11.3759732, 95.1906209, 4.45077128, -5.20261014, -28.0864106]'], {'decimal': '(6)'}), '(x_out[:, (0)], [0.18340451, 0.611852895, \n    0.785175961, -9.7271235, 310.86617, -982.725656, -7.7222893, -\n    11.3759732, 95.1906209, 4.45077128, -5.20261014, -28.0864106], decimal=6)\n', (14759, 14946), True, 'import numpy as np\n'), ((15511, 15637), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.6158501, 0.50313626, 0.64241928, 0.91952705, -39.04876174, 45.31837288]'], {}), '(x_out[:, (0)], [0.6158501, 0.50313626, \n    0.64241928, 0.91952705, -39.04876174, 45.31837288])\n', (15541, 15637), True, 'import numpy as np\n'), ((15744, 15881), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.18340451, 0.611852895, 0.785175961, -9.7271235, 310.86617, -982.725656]'], {'decimal': '(6)'}), '(x_out[:, (0)], [0.18340451, 0.611852895, \n    0.785175961, -9.7271235, 310.86617, -982.725656], decimal=6)\n', (15774, 15881), True, 'import numpy as np\n'), ((16119, 16328), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.6158501, 0.50313626, 0.64241928, 1.07179622, -33.76217857, 36.21815923, \n    46.87928022, -1.80189035, 53.3914525, 48.30056919, 63.69373374, -\n    28.15700995]'], {}), '(x_out[:, (0)], [0.6158501, 0.50313626, \n    0.64241928, 1.07179622, -33.76217857, 36.21815923, 46.87928022, -\n    1.80189035, 53.3914525, 48.30056919, 63.69373374, -28.15700995])\n', (16149, 16328), True, 'import numpy as np\n'), ((16793, 17012), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.18340451, 0.611852895, 0.785175961, -9.29662878, 300.872062, -950.354903,\n    8.60630831, 3.19433638, 29.7405608, -20.2754226, -23.2467778, -41.9135012]'], {'decimal': '(6)'}), '(x_out[:, (0)], [0.18340451, 0.611852895, \n    0.785175961, -9.29662878, 300.872062, -950.354903, 8.60630831, \n    3.19433638, 29.7405608, -20.2754226, -23.2467778, -41.9135012], decimal=6)\n', (16823, 17012), True, 'import numpy as np\n'), ((17574, 17714), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.615850098, 0.503136259, 0.642419278, -8.06478367, 242.279101, -772.114103]'], {'decimal': '(6)'}), '(x_out[:, (0)], [0.615850098, 0.503136259, \n    0.642419278, -8.06478367, 242.279101, -772.114103], decimal=6)\n', (17604, 17714), True, 'import numpy as np\n'), ((17863, 18002), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.18340451, 0.611852895, 0.785175961, -3.80892207, 120.476051, -433.291346]'], {'decimal': '(6)'}), '(x_out[:, (0)], [0.18340451, 0.611852895, \n    0.785175961, -3.80892207, 120.476051, -433.291346], decimal=6)\n', (17893, 18002), True, 'import numpy as np\n'), ((18218, 18427), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.6158501, 0.50313626, 0.64241928, 0.91952705, -39.04876174, 45.31837288, \n    55.65557816, 50.47052688, 0.36025589, 58.92377491, 29.70094194, -\n    15.13534937]'], {}), '(x_out[:, (0)], [0.6158501, 0.50313626, \n    0.64241928, 0.91952705, -39.04876174, 45.31837288, 55.65557816, \n    50.47052688, 0.36025589, 58.92377491, 29.70094194, -15.13534937])\n', (18248, 18427), True, 'import numpy as np\n'), ((18892, 19109), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.18340451, 0.611852895, 0.785175961, -9.7271235, 310.86617, -982.725656, \n    -7.7222893, -11.3759732, 95.1906209, 4.45077128, -5.20261014, -28.0864106]'], {'decimal': '(6)'}), '(x_out[:, (0)], [0.18340451, 0.611852895, \n    0.785175961, -9.7271235, 310.86617, -982.725656, -7.7222893, -\n    11.3759732, 95.1906209, 4.45077128, -5.20261014, -28.0864106], decimal=6)\n', (18922, 19109), True, 'import numpy as np\n'), ((19674, 19800), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.6158501, 0.50313626, 0.64241928, 0.91952705, -39.04876174, 45.31837288]'], {}), '(x_out[:, (0)], [0.6158501, 0.50313626, \n    0.64241928, 0.91952705, -39.04876174, 45.31837288])\n', (19704, 19800), True, 'import numpy as np\n'), ((19907, 20044), 'numpy.testing.assert_almost_equal', 'np.testing.assert_almost_equal', (['x_out[:, (0)]', '[0.18340451, 0.611852895, 0.785175961, -9.7271235, 310.86617, -982.725656]'], {'decimal': '(6)'}), '(x_out[:, (0)], [0.18340451, 0.611852895, \n    0.785175961, -9.7271235, 310.86617, -982.725656], decimal=6)\n', (19937, 20044), True, 'import numpy as np\n')]