<commit_before>import numpy as np
from numba import njit as jit

from poliastro.core.angles import E_to_M, E_to_nu, nu_to_E
from poliastro.core.elements import coe2rv, rv2coe


@jit
def recseries_coe(k, p, ecc, inc, raan, argp, nu, tof, order=8):

    # semi-major axis
    semi_axis_a = p / (1 - ecc ** 2)
    # mean angular motion
    n = np.sqrt(k / np.abs(semi_axis_a) ** 3)

    if ecc == 0:
        # Solving for circular orbit

        # compute initial mean anoamly
        M0 = nu  # For circular orbit (M = E = nu)
        # final mean anaomaly
        M = M0 + n * tof
        # snapping anomaly to [0,pi] range
        nu = M - 2 * np.pi * np.floor(M / 2 / np.pi)

        return nu

    elif ecc < 1.0:
        # Solving for elliptical orbit

        # compute initial mean anoamly
        M0 = E_to_M(nu_to_E(nu, ecc), ecc)
        # final mean anaomaly
        M = M0 + n * tof
        # snapping anomaly to [0,pi] range
        M = M - 2 * np.pi * np.floor(M / 2 / np.pi)

        # compute eccentric anomaly through recursive series
        E = M + e # Using initial guess from vallado to improve convergence
        for i in range(0, order):
            E = M + ecc * np.sin(E)

        return E_to_nu(E, ecc)

    else:
        # Parabolic/Hyperbolic orbits are not supported
        raise ValueError("Parabolic/Hyperbolic orbits not supported.")

    return nu


@jit
def recseries(k, r0, v0, tof, order=8):<commit_msg>[pre-commit.ci] auto fixes from pre-commit.com hooks<commit_after>import numpy as np
from numba import njit as jit

from poliastro.core.angles import E_to_M, E_to_nu, nu_to_E
from poliastro.core.elements import coe2rv, rv2coe


@jit
def recseries_coe(k, p, ecc, inc, raan, argp, nu, tof, order=8):

    # semi-major axis
    semi_axis_a = p / (1 - ecc ** 2)
    # mean angular motion
    n = np.sqrt(k / np.abs(semi_axis_a) ** 3)

    if ecc == 0:
        # Solving for circular orbit

        # compute initial mean anoamly
        M0 = nu  # For circular orbit (M = E = nu)
        # final mean anaomaly
        M = M0 + n * tof
        # snapping anomaly to [0,pi] range
        nu = M - 2 * np.pi * np.floor(M / 2 / np.pi)

        return nu

    elif ecc < 1.0:
        # Solving for elliptical orbit

        # compute initial mean anoamly
        M0 = E_to_M(nu_to_E(nu, ecc), ecc)
        # final mean anaomaly
        M = M0 + n * tof
        # snapping anomaly to [0,pi] range
        M = M - 2 * np.pi * np.floor(M / 2 / np.pi)

        # compute eccentric anomaly through recursive series
        E = M + e  # Using initial guess from vallado to improve convergence
        for i in range(0, order):
            E = M + ecc * np.sin(E)

        return E_to_nu(E, ecc)

    else:
        # Parabolic/Hyperbolic orbits are not supported
        raise ValueError("Parabolic/Hyperbolic orbits not supported.")

    return nu


@jit
def recseries(k, r0, v0, tof, order=8):
{'fraction_non_alphanumeric': 0.09732693625771076, 'fraction_numerical': 0.015764222069910898, 'mean_word_length': 2.050156739811912, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2356761', 'n_tokens_mistral': 1074, 'n_tokens_neox': 999, 'n_words': 342}