22
22
n_samples = 5000 , random_state = RND_SEED )
23
23
24
24
25
+ def test_enn_sk_estimator ():
26
+ """Test the sklearn estimator compatibility"""
27
+ check_estimator (RepeatedEditedNearestNeighbours )
28
+
29
+
25
30
def test_renn_init ():
26
31
"""Test the initialisation of the object"""
27
32
@@ -33,13 +38,23 @@ def test_renn_init():
33
38
assert_equal (renn .size_ngh , 3 )
34
39
assert_equal (renn .kind_sel , 'all' )
35
40
assert_equal (renn .n_jobs , - 1 )
36
- assert_equal (renn .rs_ , RND_SEED )
41
+ assert_equal (renn .random_state , RND_SEED )
37
42
assert_equal (renn .verbose , verbose )
38
43
assert_equal (renn .min_c_ , None )
39
44
assert_equal (renn .maj_c_ , None )
40
45
assert_equal (renn .stats_c_ , {})
41
46
42
47
48
+ def test_renn_iter_wrong ():
49
+ """Test either if an error is raised when the numbr of iteration
50
+ is wrong"""
51
+
52
+ # Create the object
53
+ max_iter = - 1
54
+ assert_raises (ValueError , RepeatedEditedNearestNeighbours ,
55
+ max_iter = max_iter , random_state = RND_SEED )
56
+
57
+
43
58
def test_renn_fit_single_class ():
44
59
"""Test either if an error when there is a single class"""
45
60
@@ -48,7 +63,7 @@ def test_renn_fit_single_class():
48
63
# Resample the data
49
64
# Create a wrong y
50
65
y_single_class = np .zeros ((X .shape [0 ], ))
51
- assert_raises ( RuntimeError , renn .fit , X , y_single_class )
66
+ assert_warns ( RuntimeWarning , renn .fit , X , y_single_class )
52
67
53
68
54
69
def test_renn_fit ():
@@ -66,21 +81,21 @@ def test_renn_fit():
66
81
assert_equal (renn .stats_c_ [1 ], 4500 )
67
82
68
83
69
- def test_renn_transform_wt_fit ():
70
- """Test either if an error is raised when transform is called before
84
+ def test_renn_sample_wt_fit ():
85
+ """Test either if an error is raised when sample is called before
71
86
fitting"""
72
87
73
88
# Create the object
74
89
renn = RepeatedEditedNearestNeighbours (random_state = RND_SEED )
75
- assert_raises (RuntimeError , renn .transform , X , Y )
90
+ assert_raises (RuntimeError , renn .sample , X , Y )
76
91
77
92
78
- def test_renn_fit_transform ():
79
- """Test the fit transform routine"""
93
+ def test_renn_fit_sample ():
94
+ """Test the fit sample routine"""
80
95
81
96
# Resample the data
82
97
renn = RepeatedEditedNearestNeighbours (random_state = RND_SEED )
83
- X_resampled , y_resampled = renn .fit_transform (X , Y )
98
+ X_resampled , y_resampled = renn .fit_sample (X , Y )
84
99
85
100
currdir = os .path .dirname (os .path .abspath (__file__ ))
86
101
X_gt = np .load (os .path .join (currdir , 'data' , 'renn_x.npy' ))
@@ -89,13 +104,13 @@ def test_renn_fit_transform():
89
104
assert_array_equal (y_resampled , y_gt )
90
105
91
106
92
- def test_renn_fit_transform_with_indices ():
93
- """Test the fit transform routine with indices support"""
107
+ def test_renn_fit_sample_with_indices ():
108
+ """Test the fit sample routine with indices support"""
94
109
95
110
# Resample the data
96
111
renn = RepeatedEditedNearestNeighbours (return_indices = True ,
97
112
random_state = RND_SEED )
98
- X_resampled , y_resampled , idx_under = renn .fit_transform (X , Y )
113
+ X_resampled , y_resampled , idx_under = renn .fit_sample (X , Y )
99
114
100
115
currdir = os .path .dirname (os .path .abspath (__file__ ))
101
116
X_gt = np .load (os .path .join (currdir , 'data' , 'renn_x.npy' ))
@@ -106,13 +121,13 @@ def test_renn_fit_transform_with_indices():
106
121
assert_array_equal (idx_under , idx_gt )
107
122
108
123
109
- def test_renn_fit_transform_mode ():
110
- """Test the fit transform routine using the mode as selection"""
124
+ def test_renn_fit_sample_mode ():
125
+ """Test the fit sample routine using the mode as selection"""
111
126
112
127
# Resample the data
113
128
renn = RepeatedEditedNearestNeighbours (random_state = RND_SEED ,
114
129
kind_sel = 'mode' )
115
- X_resampled , y_resampled = renn .fit_transform (X , Y )
130
+ X_resampled , y_resampled = renn .fit_sample (X , Y )
116
131
117
132
currdir = os .path .dirname (os .path .abspath (__file__ ))
118
133
X_gt = np .load (os .path .join (currdir , 'data' , 'renn_x_mode.npy' ))
0 commit comments