<commit_before>import numpy as np
from pytest import raises
from pathlib import Path
from numpy.testing import assert_almost_equal

from beyond.dates import Date
from beyond.io.horizon import load

folder = Path(__file__).parent / "data" / "io" / "horizon"

def test_load():

    for idx in range(1, 6):

        ephem = load(folder.joinpath("tess_{}.txt".format(idx)).open())

        assert ephem.start == Date(2019, 4, 29, scale="TDB")
        assert ephem.stop == Date(2019, 5, 29, scale="TDB")
        assert len(ephem) == 31

        if idx == 1:
            # Type 1 has no velocity
            assert_almost_equal(ephem[0,3:], [0, 0, 0])
        elif idx == 5:
            # Type 5 has no position
            assert_almost_equal(ephem[0,:3], [0, 0, 0])

    with raises(ValueError) as e:
        ephem = load(folder.joinpath("tess_6.txt".format(idx)).open())

    assert str(e).endswith("Unknown format : '6 (LT, range, and range-rate)'")


def test_nolabel():
    ephem = load(folder.joinpath("tess_nolabel.txt").open())

    assert ephem.start == Date(2019, 4, 29, scale="TDB")
    assert ephem.stop == Date(2019, 5, 29, scale="TDB")
    assert len(ephem) == 31


def test_units():
    ephem1 = load(folder.joinpath("tess_kms.txt").open())

    assert ephem1.start == Date(2019, 4, 29, scale="TDB")
    assert ephem1.stop == Date(2019, 5, 29, scale="TDB")
    assert len(ephem1) == 31

    ephem2 = load(folder.joinpath("tess_kmd.txt").open())

    assert ephem2.start == Date(2019, 4, 29, scale="TDB")<commit_msg>test : correction following upgrade to pytest 5.0<commit_after>import numpy as np
from pytest import raises
from pathlib import Path
from numpy.testing import assert_almost_equal

from beyond.dates import Date
from beyond.io.horizon import load

folder = Path(__file__).parent / "data" / "io" / "horizon"

def test_load():

    for idx in range(1, 6):

        ephem = load(folder.joinpath("tess_{}.txt".format(idx)).open())

        assert ephem.start == Date(2019, 4, 29, scale="TDB")
        assert ephem.stop == Date(2019, 5, 29, scale="TDB")
        assert len(ephem) == 31

        if idx == 1:
            # Type 1 has no velocity
            assert_almost_equal(ephem[0,3:], [0, 0, 0])
        elif idx == 5:
            # Type 5 has no position
            assert_almost_equal(ephem[0,:3], [0, 0, 0])

    with raises(ValueError) as excinfo:
        ephem = load(folder.joinpath("tess_6.txt".format(idx)).open())

    assert str(excinfo.value).endswith("Unknown format : '6 (LT, range, and range-rate)'")


def test_nolabel():
    ephem = load(folder.joinpath("tess_nolabel.txt").open())

    assert ephem.start == Date(2019, 4, 29, scale="TDB")
    assert ephem.stop == Date(2019, 5, 29, scale="TDB")
    assert len(ephem) == 31


def test_units():
    ephem1 = load(folder.joinpath("tess_kms.txt").open())

    assert ephem1.start == Date(2019, 4, 29, scale="TDB")
    assert ephem1.stop == Date(2019, 5, 29, scale="TDB")
    assert len(ephem1) == 31

    ephem2 = load(folder.joinpath("tess_kmd.txt").open())

    assert ephem2.start == Date(2019, 4, 29, scale="TDB")
{'fraction_non_alphanumeric': 0.15431701030927836, 'fraction_numerical': 0.05154639175257732, 'mean_word_length': 3.1733870967741935, 'pattern_counts': {'":': 0, '<': 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': '6305958', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1057, 'n_words': 279}