Skip to content

Commit

Permalink
style: Add a blank line after docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
georgedouzas committed Apr 13, 2023
1 parent c5925db commit ce7524d
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 26 deletions.
2 changes: 0 additions & 2 deletions src/clover/distribution/_density.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ def _check_parameters(

def _identify_filtered_clusters(self: DensityDistributor, y: Targets) -> DensityDistributor:
"""Identify the filtered clusters."""

# Generate multi-label
multi_labels = list(zip(self.labels_, y, strict=True))

Expand All @@ -224,7 +223,6 @@ def _identify_filtered_clusters(self: DensityDistributor, y: Targets) -> Density

def _calculate_clusters_density(self: DensityDistributor, X: InputData, y: Targets) -> DensityDistributor:
"""Calculate the density of the filtered clusters."""

self.clusters_density_ = {}

# Calculate density
Expand Down
2 changes: 1 addition & 1 deletion src/clover/distribution/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _validate_fitting(self: BaseDistributor) -> BaseDistributor:
)
raise ValueError(msg)
proportions[class_label1] += proportion
if not all([np.isclose(val, 0) or np.isclose(val, 1) for val in proportions.values()]):
if not all(np.isclose(val, 0) or np.isclose(val, 1) for val in proportions.values()):
msg = (
'Intra-distribution and inter-distribution sum of proportions for each '
f'class label should be either equal to 0 or 1. Got {proportions} instead.'
Expand Down
1 change: 0 additions & 1 deletion src/clover/over_sampling/_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def clone_modify(oversampler: BaseOverSampler, class_label: int, y_in_cluster: T
Returns:
A cloned oversampler with modified number of nearest neighbors.
"""

# Clone oversampler
oversampler = clone(oversampler)

Expand Down
1 change: 0 additions & 1 deletion src/clover/over_sampling/_gsomo.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ def __init__(

def _check_estimators(self: GeometricSOMO, X: InputData, y: Targets) -> GeometricSOMO:
"""Check various estimators."""

# Check oversampler
self.oversampler_ = GeometricSMOTE(
sampling_strategy=self.sampling_strategy,
Expand Down
3 changes: 1 addition & 2 deletions src/clover/over_sampling/_kmeans_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ def __init__(

def _check_estimators(self: KMeansSMOTE, X: InputData, y: Targets) -> KMeansSMOTE:
"""Check various estimators."""

# Check oversampler
self.oversampler_ = SMOTE(
sampling_strategy=self.sampling_strategy,
Expand All @@ -208,7 +207,7 @@ def _check_estimators(self: KMeansSMOTE, X: InputData, y: Targets) -> KMeansSMOT
)
n_clusters = round((X.shape[0] - 1) * self.kmeans_estimator + 1)
self.clusterer_ = MiniBatchKMeans(n_clusters=n_clusters, random_state=self.random_state)
elif isinstance(self.kmeans_estimator, (KMeans, MiniBatchKMeans)):
elif isinstance(self.kmeans_estimator, KMeans | MiniBatchKMeans):
self.clusterer_ = clone(self.kmeans_estimator)
else:
msg = (
Expand Down
1 change: 0 additions & 1 deletion src/clover/over_sampling/_somo.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ def __init__(

def _check_estimators(self: SOMO, X: InputData, y: Targets) -> SOMO:
"""Check various estimators."""

# Import SOM
try:
from somlearn import SOM
Expand Down
6 changes: 0 additions & 6 deletions tests/over_sampling/test_gsomo.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def test_fit(k_neighbors, imbalance_ratio_threshold, distances_exponent):
Multiple cases.
"""

# Fit oversampler
gsomo = clone(GSOMO).fit(X, y)
y_count = Counter(y)
Expand Down Expand Up @@ -69,7 +68,6 @@ def test_fit_default():
Default case.
"""

# Fit oversampler
gsomo = clone(GSOMO).fit(X, y)

Expand All @@ -88,7 +86,6 @@ def test_fit_number_of_clusters(n_clusters):
Number of clusters case.
"""

# Fit oversampler
gsomo = clone(GSOMO).set_params(som_estimator=n_clusters).fit(X, y)

Expand All @@ -104,7 +101,6 @@ def test_fit_proportion_of_samples(proportion):
Proportion of samples case.
"""

# Fit oversampler
gsomo = clone(GSOMO).set_params(som_estimator=proportion).fit(X, y)

Expand All @@ -119,7 +115,6 @@ def test_som_estimator():
Clusterer case.
"""

# Fit oversampler
gsomo = clone(GSOMO).set_params(som_estimator=SOM()).fit(X, y)

Expand Down Expand Up @@ -167,7 +162,6 @@ def test_fit_resample():
Default case.
"""

# Fit oversampler
gsomo = clone(GSOMO)
_, y_res = gsomo.fit_resample(X, y)
Expand Down
6 changes: 0 additions & 6 deletions tests/over_sampling/test_kmeans_smote.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def test_fit(k_neighbors, imbalance_ratio_threshold, distances_exponent):
Multiple cases.
"""

# Fit oversampler
kmeans_smote = clone(KMEANS_SMOTE).fit(X, y)
y_count = Counter(y)
Expand Down Expand Up @@ -62,7 +61,6 @@ def test_fit_default():
Default case.
"""

# Fit oversampler
kmeans_smote = clone(KMEANS_SMOTE).fit(X, y)

Expand All @@ -77,7 +75,6 @@ def test_fit_number_of_clusters(n_clusters):
Number of clusters case.
"""

# Fit oversampler
kmeans_smote = clone(KMEANS_SMOTE).set_params(kmeans_estimator=n_clusters).fit(X, y)

Expand All @@ -92,7 +89,6 @@ def test_fit_proportion_of_samples(proportion):
Proportion of samples case.
"""

# Fit oversampler
kmeans_smote = clone(KMEANS_SMOTE).set_params(kmeans_estimator=proportion).fit(X, y)

Expand All @@ -107,7 +103,6 @@ def test_fit_kmeans_estimator(kmeans_estimator):
Clusterer case.
"""

# Fit oversampler
kmeans_smote = clone(KMEANS_SMOTE).set_params(kmeans_estimator=kmeans_estimator).fit(X, y)

Expand Down Expand Up @@ -151,7 +146,6 @@ def test_fit_resample():
Default case.
"""

# Fit oversampler
kmeans_smote = clone(KMEANS_SMOTE)
_, y_res = kmeans_smote.fit_resample(X, y)
Expand Down
6 changes: 0 additions & 6 deletions tests/over_sampling/test_somo.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def test_fit(k_neighbors, imbalance_ratio_threshold, distances_exponent):
Multiple cases.
"""

# Fit oversampler
somo = clone(SM).fit(X, y)
y_count = Counter(y)
Expand Down Expand Up @@ -67,7 +66,6 @@ def test_fit_default():
Default case.
"""

# Fit oversampler
somo = clone(SM).fit(X, y)

Expand All @@ -86,7 +84,6 @@ def test_fit_number_of_clusters(n_clusters):
Number of clusters case.
"""

# Fit oversampler
somo = clone(SM).set_params(som_estimator=n_clusters).fit(X, y)

Expand All @@ -102,7 +99,6 @@ def test_fit_proportion_of_samples(proportion):
Proportion of samples case.
"""

# Fit oversampler
somo = clone(SM).set_params(som_estimator=proportion).fit(X, y)

Expand All @@ -117,7 +113,6 @@ def test_fit_som_estimator():
Clusterer case.
"""

# Fit oversampler
somo = clone(SM).set_params(som_estimator=SOM()).fit(X, y)

Expand Down Expand Up @@ -165,7 +160,6 @@ def test_fit_resample():
Default case.
"""

# Fit oversampler
somo = clone(SM)
_, y_res = somo.fit_resample(X, y)
Expand Down

0 comments on commit ce7524d

Please sign in to comment.