
""" To test if the new code produces the same precision values on the published results."""

from __future__ import division, print_function
import pytest
import numpy as np

import eniric.Qcalculator as Q
import eniric.IOmodule as IO
from bin.prec_1 import calc_prec1

# For python2.X compatibility
file_error_to_catch = getattr(__builtins__, 'FileNotFoundError', IOError)

path = "data/Published_Results/resampled/"


@pytest.mark.xfail(raises=file_error_to_catch)   # Data file may not exist
def test_presicion_1():
    """ New precision 1 test that works."""
    published_results = {1: 3.8, 5: 9.1, 10: 20.7}
    path = "data/resampled/"
    for vsini in [1, 5, 10]:
        # name = "Spectrum_M0-PHOENIX-ACES_Yband_vsini{0}.0_R100k_res3.txt".format(vsini)
        __, p1 = calc_prec1("M0", "Y", vsini, "100k", 3, resampled_dir=path)

        assert np.round(p1, 1).value == published_results[vsini]


""" To test if the new code produces the same precision values on the published results."""

from __future__ import division, print_function
import pytest
import numpy as np

import eniric.Qcalculator as Q
import eniric.IOmodule as IO
from bin.prec_1 import calc_prec1

# For python2.X compatibility
file_error_to_catch = getattr(__builtins__, 'FileNotFoundError', IOError)

path = "data/Published_Results/resampled/"


@pytest.mark.xfail(raises=file_error_to_catch)   # Data file may not exist
def test_presicion_1():
    """ New precision 1 test that works."""
    published_results = {1: 3.8, 5: 9.1, 10: 20.7}
    path = "data/resampled/"
    for vsini in [1, 5, 10]:
        # name = "Spectrum_M0-PHOENIX-ACES_Yband_vsini{0}.0_R100k_res3.txt".format(vsini)
        __, p1 = calc_prec1("M0", "Y", vsini, "100k", 3, resampled_dir=path)

        # assert np.round(p1, 1).value == published_results[vsini]
        assert np.round(100 * p1, 1).value == published_results[vsini]  # With incorect normalization

Add known offset for known bad calibration.
Add known offset for known bad calibration.


Former-commit-id: afa3d6a66e32bbcc2b20f00f7e63fba5cb45882e [formerly 0470ca22b8a24205d2eb1c66caee912c990da0b3] [formerly c23210f4056c27e61708da2f2440bce3eda151a8 [formerly 5c0a6b9c0fefd2b88b9382d4a6ed98d9eac626df]]
Former-commit-id: 8bfdaa1f7940b26aee05f20e801616f4a8d1d55d [formerly 1c85db5b2b87b73dfb28a1db171ff79a69e3a24a]
Former-commit-id: d02a26b263c5c59776a35fc130e5c96b7ac30f5d