Skip to content

Commit c2f628d

Browse files
Fixed issues #202
1 parent 11baff2 commit c2f628d

File tree

5 files changed

+33
-5
lines changed

5 files changed

+33
-5
lines changed

instance_selection/_RNN.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def filter(self, samples, y):
4848
samples, y = cnn.filter(samples, y)
4949
samp_set = transform(samples, y)
5050

51-
data = deque([x for x in samp_set["data"]])
52-
target = deque([x for x in samp_set["target"]])
51+
data = deque(list(samp_set['data']))
52+
target = deque(list(samp_set['target']))
5353

5454
for instance in zip(samp_set.data, samp_set.target):
5555
(sample, class_sample) = instance

semisupervised/CoTraining.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ def __init__(
8383
else:
8484
configs.append(GaussianNB())
8585

86-
self.h1, self.h2 = configs
86+
try:
87+
self.h1, self.h2 = configs
88+
except ValueError:
89+
raise AttributeError("Classifiers and/or params were not "
90+
"correctly passed.")
8791

8892
def fit(self, samples, y):
8993
"""

semisupervised/DemocraticCoLearning.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,11 @@ def __init__(
9191
else:
9292
configs.append(default_classifiers[index]())
9393

94-
self.h1, self.h2, self.h3 = configs
94+
try:
95+
self.h1, self.h2, self.h3 = configs
96+
except ValueError:
97+
raise AttributeError("Classifiers and/or params were not "
98+
"correctly passed.")
9599

96100
def fit(self, samples, y):
97101
"""

semisupervised/DensityPeaks.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,25 @@ def __local_density(self):
145145
"""
146146

147147
def gauss_func(dij, dc):
148+
"""
149+
> The function takes in a distance value and a cutoff value, and
150+
returns the value of the Gaussian function at that point
151+
152+
:param dij: distance between two nodes
153+
:param dc: The cutoff distance
154+
:return: the value of the gaussian function.
155+
"""
148156
return math.exp(-((dij / dc) ** 2))
149157

150158
def cutoff_func(dij, dc):
159+
"""
160+
If the distance between two atoms is less than the cutoff distance,
161+
return 1, otherwise return 0
162+
163+
:param dij: distance between atoms i and j
164+
:param dc: cutoff distance
165+
:return: 1 if dij < dc, else 0
166+
"""
151167
return 1 if dij < dc else 0
152168

153169
func = gauss_func if self.gauss_cutoff else cutoff_func

semisupervised/TriTraining.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ def __init__(
8484
else:
8585
configs.append(default_classifiers[index]())
8686

87-
self.hj, self.hk, self.hi = configs
87+
try:
88+
self.hj, self.hk, self.hi = configs
89+
except ValueError:
90+
raise AttributeError("Classifiers and/or params were not "
91+
"correctly passed.")
8892

8993
self.random_state = (
9094
random_state

0 commit comments

Comments
 (0)