Skip to content

Commit b75b77d

Browse files
committed
make testing function private
1 parent 615a2bf commit b75b77d

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

imblearn/over_sampling/tests/test_common.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
SMOTENC,
1313
SVMSMOTE,
1414
)
15-
from imblearn.utils.testing import CustomNearestNeighbors
15+
from imblearn.utils.testing import _CustomNearestNeighbors
1616

1717

1818
@pytest.fixture
@@ -76,7 +76,7 @@ def test_smote_m_neighbors(numerical_data, smote):
7676
def test_numerical_smote_custom_nn(numerical_data, smote, neighbor_estimator_name):
7777
X, y = numerical_data
7878
params = {
79-
neighbor_estimator_name: CustomNearestNeighbors(n_neighbors=5),
79+
neighbor_estimator_name: _CustomNearestNeighbors(n_neighbors=5),
8080
}
8181
smote.set_params(**params)
8282
X_res, _ = smote.fit_resample(X, y)
@@ -86,7 +86,7 @@ def test_numerical_smote_custom_nn(numerical_data, smote, neighbor_estimator_nam
8686

8787
def test_categorical_smote_k_custom_nn(categorical_data):
8888
X, y = categorical_data
89-
smote = SMOTEN(k_neighbors=CustomNearestNeighbors(n_neighbors=5))
89+
smote = SMOTEN(k_neighbors=_CustomNearestNeighbors(n_neighbors=5))
9090
X_res, y_res = smote.fit_resample(X, y)
9191

9292
assert X_res.shape == (80, 3)
@@ -96,7 +96,7 @@ def test_categorical_smote_k_custom_nn(categorical_data):
9696
def test_heterogeneous_smote_k_custom_nn(heterogeneous_data):
9797
X, y, categorical_features = heterogeneous_data
9898
smote = SMOTENC(
99-
categorical_features, k_neighbors=CustomNearestNeighbors(n_neighbors=5)
99+
categorical_features, k_neighbors=_CustomNearestNeighbors(n_neighbors=5)
100100
)
101101
X_res, y_res = smote.fit_resample(X, y)
102102

@@ -111,7 +111,7 @@ def test_heterogeneous_smote_k_custom_nn(heterogeneous_data):
111111
)
112112
def test_numerical_smote_extra_custom_nn(numerical_data, smote):
113113
X, y = numerical_data
114-
smote.set_params(m_neighbors=CustomNearestNeighbors(n_neighbors=5))
114+
smote.set_params(m_neighbors=_CustomNearestNeighbors(n_neighbors=5))
115115
X_res, y_res = smote.fit_resample(X, y)
116116

117117
assert X_res.shape == (120, 2)

imblearn/under_sampling/_prototype_generation/tests/test_cluster_centroids.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from sklearn.datasets import make_classification
1111

1212
from imblearn.under_sampling import ClusterCentroids
13-
from imblearn.utils.testing import CustomClusterer
13+
from imblearn.utils.testing import _CustomClusterer
1414

1515
RND_SEED = 0
1616
X = np.array(
@@ -170,4 +170,4 @@ def test_cluster_centroids_error_estimator():
170170
"`cluster_centers_`."
171171
)
172172
with pytest.raises(RuntimeError, match=err_msg):
173-
ClusterCentroids(estimator=CustomClusterer()).fit_resample(X, Y)
173+
ClusterCentroids(estimator=_CustomClusterer()).fit_resample(X, Y)

imblearn/utils/testing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def warns(expected_warning, match=None):
168168
pass
169169

170170

171-
class CustomNearestNeighbors(BaseEstimator):
171+
class _CustomNearestNeighbors(BaseEstimator):
172172
"""Basic implementation of nearest neighbors not relying on scikit-learn.
173173
174174
`kneighbors_graph` is ignored and `metric` does not have any impact.
@@ -197,7 +197,7 @@ def kneighbors_graph(X=None, n_neighbors=None, mode="connectivity"):
197197
pass
198198

199199

200-
class CustomClusterer(BaseEstimator):
200+
class _CustomClusterer(BaseEstimator):
201201
"""Class that mimics a cluster that does not expose `cluster_centers_`."""
202202

203203
def __init__(self, n_clusters=1):

imblearn/utils/tests/test_testing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from sklearn.neighbors._base import KNeighborsMixin
1111

1212
from imblearn.base import SamplerMixin
13-
from imblearn.utils.testing import all_estimators, CustomNearestNeighbors
13+
from imblearn.utils.testing import all_estimators, _CustomNearestNeighbors
1414

1515
from imblearn.utils.testing import warns
1616

@@ -69,7 +69,7 @@ def test_custom_nearest_neighbors():
6969
"""Check that our custom nearest neighbors can be used for our internal
7070
duck-typing."""
7171

72-
neareat_neighbors = CustomNearestNeighbors(n_neighbors=3)
72+
neareat_neighbors = _CustomNearestNeighbors(n_neighbors=3)
7373

7474
assert not isinstance(neareat_neighbors, KNeighborsMixin)
7575
assert hasattr(neareat_neighbors, "kneighbors")

0 commit comments

Comments
 (0)