Skip to content

Commit 9234e05

Browse files
authored
Improve coverage on Peirce criterion (#46)
* Improve coverage on Peirce criterion * Increase `n` such that `ldiv` goes to zero numerically
1 parent fa34ba3 commit 9234e05

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/func/utilities/test_peirce.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,45 @@
11
"""Test for Peirce criterion data rejection."""
22

33

4+
from hypothesis import given, strategies as st
45
import pytest
56
import numpy as np
67

78
from rimseval.utilities import peirce
89

910

11+
def test_peirce_criterion_ldiv_zero():
12+
"""Choose a minimum ldiv if it is zero (erfc turns 0 at large values)."""
13+
# define values such that it turns out to be zero
14+
n_tot = 100
15+
n = 1e3 # this brings `ldiv` numerically to zero
16+
m = 1
17+
18+
_ = peirce.peirce_criterion(n_tot, n, m)
19+
20+
21+
@given(n_hyp=st.integers(), m_hyp=st.integers())
22+
def test_peirce_criterion_n_tot_zero(n_hyp, m_hyp):
23+
"""Check that setting number of observations to zero returns zero always."""
24+
n_tot = 0
25+
expected = 0
26+
received = peirce.peirce_criterion(n_tot, n_hyp, m_hyp)
27+
assert expected == received
28+
29+
30+
def test_peirce_criterion_x2_less_zero():
31+
"""Ensure that in while-loop, x2 is set to zero if it is smaller than zero."""
32+
# define values that get x2 < 0
33+
n_tot = 2
34+
n = 1
35+
m = 5
36+
37+
expected = 0
38+
received = peirce.peirce_criterion(n_tot, n, m)
39+
40+
assert expected == received
41+
42+
1043
def test_peirce_ross_2003_example():
1144
"""Run example in Ross (2003) through Peirce criterion."""
1245
data = np.array([102.2, 90, 99, 102, 103, 100.2, 89, 98.1, 101.5, 102])

0 commit comments

Comments
 (0)