-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathtest_5_parametric.py
31 lines (28 loc) · 1.01 KB
/
test_5_parametric.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
test for rtanalysis
- in this test, we will try various parameter levels
and make sure that the function properly raises
and exception is accuracy is zero
"""
import numpy as np
import pytest
from rtanalysis.generate_testdata import generate_test_df
from rtanalysis.rtanalysis import RTAnalysis
@pytest.mark.parametrize(
"meanRT, sdRT, meanAcc", [(1.5, 1.0, 0.9), (1500, 1000, 0.9), (1.5, 1.0, 0)]
)
def test_rtanalysis_parameteric(meanRT, sdRT, meanAcc):
test_df = generate_test_df(meanRT, sdRT, meanAcc)
rta = RTAnalysis()
if min(test_df.rt) <= 0:
# make sure it catches the rt < 0 error
with pytest.raises(ValueError):
rta.fit(test_df.rt, test_df.accuracy)
elif meanAcc > 0:
rta.fit(test_df.rt, test_df.accuracy)
assert np.allclose(meanRT, rta.mean_rt_)
assert np.allclose(meanAcc, rta.mean_accuracy_)
else:
# make sure it catches the zero accuracy error
with pytest.raises(ValueError):
rta.fit(test_df.rt, test_df.accuracy)