Exemplo n.º 1
0
def test_invalid_rt_has_none_ri(invalid_rt_data, indexed_data):
    method = Kovats()

    expected = [None, None, None, 741.5254237288136]
    actual = method.compute(invalid_rt_data, indexed_data)

    numpy.testing.assert_array_equal(actual, expected)
Exemplo n.º 2
0
def test_exception_query_none(indexed_data):
    method = Kovats()
    with pytest.raises(AssertionError) as exception:
        method.compute(None, indexed_data)

    message = exception.value.args[0]
    assert exception.typename == "AssertionError"
    assert message == "Query data is 'None'."
Exemplo n.º 3
0
def test_exception_reference_none(non_indexed_data):
    method = Kovats()
    with pytest.raises(AssertionError) as exception:
        method.compute(non_indexed_data, None)

    message = exception.value.args[0]
    assert exception.typename == "AssertionError"
    assert message == "Reference data is 'None'."
Exemplo n.º 4
0
def test_compute_ri_basic_case(non_indexed_data, indexed_data):
    method = Kovats()

    expected = [
        741.525424, 760.169492, 769.491525, 932.420091, 965.296804, 986.757991,
        1078.823529, 1157.142857
    ]
    actual = method.compute(non_indexed_data, indexed_data)

    numpy.testing.assert_array_almost_equal(actual, expected)
Exemplo n.º 5
0
    def __call__(self, parser, namespace, values, option_string=None):
        """Function to be called on action invocation

        Args:
            parser (argparse.ArgumentParser): Passed implicitly.
            namespace ([type]): Passed implicitly.
            values (str): Method name indicating which method to use.
            option_string (str, optional): Unused. Defaults to None.
        """
        if values not in ['kovats', 'cubicspline']:
            raise AssertionError(
                "Method must be one of ['cubicspline', 'kovats'].")

        if values == "kovats":
            method = Kovats()
        elif values == "cubicspline":
            method = CubicSpline()

        setattr(namespace, self.dest, method)
Exemplo n.º 6
0
def load_method(method):
    if method == 'kovats':
        return Kovats()
    if method == 'cubicspline':
        return CubicSpline()
    return None
Exemplo n.º 7
0
import pytest

from RIAssigner.compute import ComputationMethod, CubicSpline, Kovats


@pytest.mark.parametrize('this, other, expected', [
    [CubicSpline(), CubicSpline(), True],
    [Kovats(), Kovats(), True],
    [CubicSpline(), Kovats(), False],
    [Kovats(), object(), False],
    [CubicSpline(), object(), False],
])
def test_equal(this, other, expected):
    actual = (this == other)
    assert actual == expected


def test_abc():
    with pytest.raises(TypeError) as exception:
        method = ComputationMethod()

    message = exception.value.args[0]
    assert exception.typename == "TypeError"
    assert str(message).startswith(
        "Can't instantiate abstract class ComputationMethod with abstract method"
    )
Exemplo n.º 8
0
def test_construct():
    compute = Kovats()
    assert compute is not None
Exemplo n.º 9
0
def test_ref_queries(reference_alkanes, queries):
    method = Kovats()

    data, expected = queries
    actual = method.compute(data, reference_alkanes)
    numpy.testing.assert_array_almost_equal(actual, expected)