import pytest

import numpy as np

from fanok.selection import adaptive_significance_threshold


@pytest.mark.parametrize(
    "w, q, offset, expected",
    [
        ([1, 2, 3, 4, 5], 0.1, 0, 1),
        ([-1, 2, -3, 4, 5], 0.1, 0, 4),
        ([-3, -2, -1, 0, 1, 2, 3], 0.1, 0, np.inf),
        ([-3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 0.1, 0, 4),
        ([-3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 0.15, 0, 3),
        (
            [-1.52, 1.93, -0.76, -0.35, 1.21, -0.39, 0.08, -1.45, 0.31, -1.38],
            0.1,
            0,
            1.93,
        ),
    ],
)
def test_adaptive_significance_threshold(w, q, offset, expected):
    w = np.array(w)
    threshold = adaptive_significance_threshold(w, q, offset=offset)
    assert threshold == expected

[((8, 1, 23, 1), 'pytest.mark.parametrize', 'pytest.mark.parametrize', ({(9, 4, 9, 28): '"""w, q, offset, expected"""', (10, 4, 22, 5): '[([1, 2, 3, 4, 5], 0.1, 0, 1), ([-1, 2, -3, 4, 5], 0.1, 0, 4), ([-3, -2, -1,\n    0, 1, 2, 3], 0.1, 0, np.inf), ([-3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, \n    9, 10], 0.1, 0, 4), ([-3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], \n    0.15, 0, 3), ([-1.52, 1.93, -0.76, -0.35, 1.21, -0.39, 0.08, -1.45, \n    0.31, -1.38], 0.1, 0, 1.93)]'}, {}), "('w, q, offset, expected', [([1, 2, 3, 4, 5], 0.1, 0,\n    1), ([-1, 2, -3, 4, 5], 0.1, 0, 4), ([-3, -2, -1, 0, 1, 2, 3], 0.1, 0,\n    np.inf), ([-3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 0.1, 0, 4), (\n    [-3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 0.15, 0, 3), ([-1.52, \n    1.93, -0.76, -0.35, 1.21, -0.39, 0.08, -1.45, 0.31, -1.38], 0.1, 0, 1.93)])", False, 'import pytest\n'), ((25, 8, 25, 19), 'numpy.array', 'np.array', ({(25, 17, 25, 18): 'w'}, {}), '(w)', True, 'import numpy as np\n'), ((26, 16, 26, 68), 'fanok.selection.adaptive_significance_threshold', 'adaptive_significance_threshold', (), '', False, 'from fanok.selection import adaptive_significance_threshold\n')]