Skip to content

Commit fc43a67

Browse files
Code style #207
1 parent 4117b62 commit fc43a67

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

semisupervised/DensityPeaks.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(
7171
self.filter = None
7272

7373
self.y = None
74-
self.l = None
74+
self.low = None
7575
self.u = None
7676
self.classifier_stdpnf = None
7777
self.order = None
@@ -198,9 +198,13 @@ def __min_neighbor_and_distance(self):
198198
199199
:return: distance vector, nearest neighbor vector
200200
"""
201+
if self.rho is None:
202+
raise ValueError("Encountered rho as None.")
203+
201204
sort_rho_idx = np.argsort(-self.rho)
202205
delta, nneigh = [float(self.max_dis)] * self.n_id, [0] * self.n_id
203206
delta[sort_rho_idx[0]] = -1.0
207+
204208
for i in range(self.n_id):
205209
for j in range(0, i):
206210
old_i, old_j = sort_rho_idx[i], sort_rho_idx[j]
@@ -359,20 +363,20 @@ def __enane(self, fx, nan, r):
359363

360364
return es, es_pred
361365

362-
def __init_values(self, l, u, y):
366+
def __init_values(self, low, u, y):
363367
"""
364368
It takes in the lower and upper bounds of the data, and the data itself,
365369
and then calculates the distances between the data points,
366370
the maximum distance, the minimum distance, the dc value, the rho
367371
value, the delta value, the number of neighbors, and the structure
368372
of the data
369373
370-
:param l: lower bound of the data
374+
:param low: lower bound of the data
371375
:param u: upper bound of the data
372376
:param y: the labels of the data
373377
"""
374378
self.y = y
375-
self.l = l
379+
self.low = low
376380
self.u = u
377381
self.data = np.concatenate((l, u), axis=0)
378382
self.n_id = self.data.shape[0]
@@ -470,7 +474,7 @@ def _fit_stdpnf(self):
470474
self.classifier_stdpnf = KNeighborsClassifier(
471475
n_neighbors=self.k, metric=self.distance_metric
472476
)
473-
self.classifier_stdpnf.fit(self.l, self.y)
477+
self.classifier_stdpnf.fit(self.low, self.y)
474478
count = 1
475479

476480
while count <= max(self.order.values()):
@@ -546,7 +550,7 @@ def _if_filter(self, complete, complete_y):
546550
:return: The result is a dataframe with the filtered data.
547551
"""
548552
if isinstance(self.filter, ENN):
549-
original = pd.DataFrame(self.l)
553+
original = pd.DataFrame(self.low)
550554
original_y = pd.DataFrame(self.y)
551555
result, _ = self.filter.filter_original_complete(
552556
original, original_y, complete, complete_y

utils/arff2dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def arff_data(dataset_path, attr=False):
2020
defaults to False (optional)
2121
:return: A bunch object with the data, target and attributes.
2222
"""
23-
if not ".arff" in str(dataset_path).lower():
23+
if ".arff" not in str(dataset_path).lower():
2424
raise ValueError("File does not an ARFF extension.")
2525
file = open(dataset_path, "r")
2626
attrs, data = _read_file(file)

0 commit comments

Comments
 (0)