Skip to content

Commit 5888ff7

Browse files
committed
update unit tests for preproces-sampling; fix cleaning err msg to have "do not"; add cleaning test for minority error
1 parent b8c8a8e commit 5888ff7

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

imblearn/utils/tests/test_validation.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,14 @@ def test_check_target_type_ova(target, output_target, is_ova):
6868
assert binarize_target == is_ova
6969

7070

71-
def test_check_sampling_strategy_warning():
72-
msg = "dict for cleaning methods is not supported"
71+
@pytest.mark.parametrize(
72+
"sampling_method", ["clean-sampling", "preprocess-sampling"]
73+
)
74+
def test_check_sampling_strategy_warning(sampling_method):
75+
msg = "dict for cleaning or preprocess methods is not supported"
7376
with pytest.raises(ValueError, match=msg):
7477
check_sampling_strategy(
75-
{1: 0, 2: 0, 3: 0}, multiclass_target, "clean-sampling"
78+
{1: 0, 2: 0, 3: 0}, multiclass_target, sampling_method
7679
)
7780

7881

@@ -83,7 +86,13 @@ def test_check_sampling_strategy_warning():
8386
0.5,
8487
binary_target,
8588
"clean-sampling",
86-
"'clean-sampling' methods do let the user specify the sampling ratio", # noqa
89+
"-sampling' methods do not let the user specify the sampling ratio",
90+
),
91+
(
92+
0.5,
93+
binary_target,
94+
"preprocess-sampling",
95+
"-sampling' methods do not let the user specify the sampling ratio",
8796
),
8897
(
8998
0.1,
@@ -122,6 +131,7 @@ def test_check_sampling_strategy_error():
122131
[
123132
("majority", "over-sampling", "over-sampler"),
124133
("minority", "under-sampling", "under-sampler"),
134+
("minority", "clean-sampling", "under-sampler"),
125135
],
126136
)
127137
def test_check_sampling_strategy_error_wrong_string(

0 commit comments

Comments
 (0)