<commit_before>import erfa
from astropy import units as u
from astropy.coordinates.solar_system import PLAN94_BODY_NAME_TO_PLANET_INDEX

from ..constants import J2000
from ..frames import Planes
from .states import RVState


def get_mean_elements(body, epoch=J2000):
    """Get ecliptic mean elements of body.

    Parameters
    ----------
    body : ~poliastro.bodies.SolarSystemPlanet
        Body.
    epoch : astropy.time.Time
        Epoch.

    """
    # Internally, erfa.plan94 has a table of classical elements,
    # which are then converted to position and velocity...
    # So we are reverting the conversion in the last line
    # This way at least we avoid copy pasting the values
    try:
        name = body.name.lower()
        if name not in PLAN94_BODY_NAME_TO_PLANET_INDEX:
            raise ValueError(
                f"The input body '{body}' is invalid. It must be an instance of `poliastro.bodies.SolarSystemPlanet`."
            )
        if name == "earth":
            name = "earth-moon-barycenter"

        body_index = PLAN94_BODY_NAME_TO_PLANET_INDEX[name]
        body_pv_helio = erfa.plan94(epoch.jd1, epoch.jd2, body_index)

        r = body_pv_helio["p"] * u.au
        v = body_pv_helio["v"] * u.au / u.day

    except KeyError as e:
        raise ValueError(f"No available mean elements for {body}") from e

    return RVState(body.parent, r, v, plane=Planes.EARTH_ECLIPTIC).to_classical()<commit_msg>Change placement of condition<commit_after>import erfa
from astropy import units as u
from astropy.coordinates.solar_system import PLAN94_BODY_NAME_TO_PLANET_INDEX

from ..constants import J2000
from ..frames import Planes
from .states import RVState


def get_mean_elements(body, epoch=J2000):
    """Get ecliptic mean elements of body.

    Parameters
    ----------
    body : ~poliastro.bodies.SolarSystemPlanet
        Body.
    epoch : astropy.time.Time
        Epoch.

    """
    # Internally, erfa.plan94 has a table of classical elements,
    # which are then converted to position and velocity...
    # So we are reverting the conversion in the last line
    # This way at least we avoid copy pasting the values
    try:
        name = body.name.lower()

        if name == "earth":
            name = "earth-moon-barycenter"

        if name not in PLAN94_BODY_NAME_TO_PLANET_INDEX:
            raise ValueError(
                f"The input body '{body}' is invalid. It must be an instance of `poliastro.bodies.SolarSystemPlanet`."
            )

        body_index = PLAN94_BODY_NAME_TO_PLANET_INDEX[name]
        body_pv_helio = erfa.plan94(epoch.jd1, epoch.jd2, body_index)

        r = body_pv_helio["p"] * u.au
        v = body_pv_helio["v"] * u.au / u.day

    except KeyError as e:
        raise ValueError(f"No available mean elements for {body}") from e

    return RVState(body.parent, r, v, plane=Planes.EARTH_ECLIPTIC).to_classical()
{'fraction_non_alphanumeric': 0.08770718232044199, 'fraction_numerical': 0.013812154696132596, 'mean_word_length': 2.6670886075949367, 'pattern_counts': {'":': 2, '<': 3, '<?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': '5885725', 'n_tokens_mistral': 968, 'n_tokens_neox': 917, 'n_words': 272}