Skip to content

Commit 1a42592

Browse files
committed
update docstring
1 parent be837e0 commit 1a42592

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

test/test_base_variable_importance.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@
66

77
@pytest.fixture
88
def set_BaseVariableImportance(pvalues, test_score, seed):
9+
"""Create a BaseVariableImportance instance with test data for testing purposes.
10+
11+
Parameters
12+
----------
13+
pvalues : bool
14+
If True, generate random p-values for testing.
15+
test_score : bool
16+
If True, generate random test scores for testing.
17+
seed : int
18+
Random seed for reproducibility.
19+
20+
Returns
21+
-------
22+
BaseVariableImportance
23+
A BaseVariableImportance instance with test data.
24+
"""
925
nb_features = 100
1026
rng = np.random.RandomState(seed)
1127
vi = BaseVariableImportance()
@@ -14,6 +30,7 @@ def set_BaseVariableImportance(pvalues, test_score, seed):
1430
if pvalues or test_score:
1531
vi.pvalues_ = np.sort(rng.rand(nb_features))[vi.importances_]
1632
if test_score:
33+
# TODO: this can be improved.
1734
vi.test_scores_ = []
1835
for i in range(10):
1936
score = np.random.rand(nb_features) * 30
@@ -32,7 +49,7 @@ def set_BaseVariableImportance(pvalues, test_score, seed):
3249
ids=["only importance", "p-value", "test-score"],
3350
)
3451
class TestSelection:
35-
"""Test selection base on importance"""
52+
"""Test selection based on importance"""
3653

3754
def test_selection_k_best(self, set_BaseVariableImportance):
3855
"test selection of the k_best"
@@ -109,7 +126,7 @@ def test_selection_threshold_pvalue(self, set_BaseVariableImportance):
109126
"pvalues, test_score, seed", [(True, True, 10)], ids=["default"]
110127
)
111128
class TestSelectionFDR:
112-
"""Test selection base on fdr"""
129+
"""Test selection based on fdr"""
113130

114131
def test_selection_fdr_default(self, set_BaseVariableImportance):
115132
"test selection of the default"
@@ -126,14 +143,14 @@ def test_selection_fdr_adaptation(self, set_BaseVariableImportance):
126143
np.testing.assert_array_equal(true_value, selection)
127144

128145
def test_selection_fdr_bhy(self, set_BaseVariableImportance):
129-
"test selection of the adaptation"
146+
"test selection with bhy"
130147
vi = set_BaseVariableImportance
131148
true_value = vi.importances_ >= 85
132149
selection = vi.selection_fdr(0.8, fdr_control="bhy")
133150
np.testing.assert_array_equal(true_value, selection)
134151

135152
def test_selection_fdr_ebh(self, set_BaseVariableImportance):
136-
"test selection of the adaptation"
153+
"test selection with e-values"
137154
vi = set_BaseVariableImportance
138155
true_value = vi.importances_ >= 2
139156
selection = vi.selection_fdr(0.037, fdr_control="ebh", evalues=True)

0 commit comments

Comments
 (0)