@@ -106,7 +106,7 @@ def _sample(self, X, y):
106106
107107 # If we need to offer support for the indices
108108 if self .return_indices :
109- idx_under = np .nonzero (y == self .min_c_ )[ 0 ]
109+ idx_under = np .flatnonzero (y == self .min_c_ )
110110
111111 # Create a k-NN to fit the whole data
112112 nn_obj = NearestNeighbors (n_neighbors = self .size_ngh ,
@@ -123,7 +123,7 @@ def _sample(self, X, y):
123123 sub_samples_x = X [y == key ]
124124
125125 # Get the samples associated
126- idx_sub_sample = np .nonzero (y == key )[ 0 ]
126+ idx_sub_sample = np .flatnonzero (y == key )
127127
128128 # Find the NN for the current class
129129 nnhood_idx = nn_obj .kneighbors (sub_samples_x ,
@@ -140,7 +140,7 @@ def _sample(self, X, y):
140140 if key == self .min_c_ :
141141 # Get the index to exclude
142142 idx_to_exclude += nnhood_idx [np .nonzero (
143- nnhood_label [np .nonzero (nnhood_bool )])].tolist ()
143+ nnhood_label [np .flatnonzero (nnhood_bool )])].tolist ()
144144 else :
145145 # Get the index to exclude
146146 idx_to_exclude += idx_sub_sample [np .nonzero (
@@ -156,12 +156,12 @@ def _sample(self, X, y):
156156 sel_idx [y == self .min_c_ ] = 0
157157
158158 # Get the samples from the majority classes
159- sel_x = np . squeeze ( X [np .nonzero (sel_idx ), :])
160- sel_y = y [np .nonzero (sel_idx )]
159+ sel_x = X [np .flatnonzero (sel_idx ), :]
160+ sel_y = y [np .flatnonzero (sel_idx )]
161161
162162 # If we need to offer support for the indices selected
163163 if self .return_indices :
164- idx_tmp = np .nonzero (sel_idx )[ 0 ]
164+ idx_tmp = np .flatnonzero (sel_idx )
165165 idx_under = np .concatenate ((idx_under , idx_tmp ), axis = 0 )
166166
167167 X_resampled = np .concatenate ((X_resampled , sel_x ), axis = 0 )
0 commit comments