Skip to content

Commit 02f76d0

Browse files
committed
more style updates
1 parent 10fbbf5 commit 02f76d0

File tree

10 files changed

+22
-26
lines changed

10 files changed

+22
-26
lines changed

.prospector.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ strictness: high
22
max-line-length: 90
33
ignore-paths:
44
- setup.py
5-
- examples/
6-
- .github/
5+
- examples
6+
- .github
77
python-targets:
88
- 3
99
pep8:
@@ -23,5 +23,4 @@ pylint:
2323
min-public-methods: 1
2424
bandit:
2525
options:
26-
skips:
27-
- B301
26+
skips: ['B301']

kmodes/kmodes.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,8 @@ def predict(self, X, **kwargs):
175175
def cluster_centroids_(self):
176176
if hasattr(self, '_enc_cluster_centroids'):
177177
return decode_centroids(self._enc_cluster_centroids, self._enc_map)
178-
else:
179-
raise AttributeError("'{}' object has no attribute 'cluster_centroids_' "
180-
"because the model is not yet fitted.")
178+
raise AttributeError("'{}' object has no attribute 'cluster_centroids_' "
179+
"because the model is not yet fitted.")
181180

182181

183182
def labels_cost(X, centroids, dissim, membship=None):

kmodes/kprototypes.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
K-prototypes clustering for mixed categorical and numerical data
33
"""
44

5-
# pylint: disable=super-on-old-class,unused-argument,attribute-defined-outside-init
5+
# pylint: disable=unused-argument,attribute-defined-outside-init
66

77
from collections import defaultdict
88

@@ -203,9 +203,8 @@ def cluster_centroids_(self):
203203
self._enc_cluster_centroids[0],
204204
decode_centroids(self._enc_cluster_centroids[1], self._enc_map)
205205
))
206-
else:
207-
raise AttributeError("'{}' object has no attribute 'cluster_centroids_' "
208-
"because the model is not yet fitted.")
206+
raise AttributeError("'{}' object has no attribute 'cluster_centroids_' "
207+
"because the model is not yet fitted.")
209208

210209

211210
def labels_cost(Xnum, Xcat, centroids, num_dissim, cat_dissim, gamma, membship=None):

kmodes/tests/test_kmodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def find_splits(x):
228228
np.testing.assert_array_equal(find_splits(array1), find_splits(array2))
229229

230230

231-
# pylint: disable=R0201,W0105
231+
# pylint: disable=no-self-use,pointless-statement
232232
class TestKModes(unittest.TestCase):
233233

234234
def test_pickle(self):

kmodes/tests/test_kprototypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
])
3434

3535

36-
# pylint: disable=R0201,W0105
36+
# pylint: disable=no-self-use,pointless-statement
3737
class TestKProtoTypes(unittest.TestCase):
3838

3939
def test_pickle(self):

kmodes/util/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def get_max_value_key(dic):
1717
maxima = np.where(v == np.max(v))[0]
1818
if len(maxima) == 1:
1919
return k[maxima[0]]
20-
else:
21-
# In order to be consistent, always selects the minimum key
22-
# (guaranteed to be unique) when there are multiple maximum values.
23-
return k[maxima[np.argmin(k[maxima])]]
20+
21+
# In order to be consistent, always selects the minimum key
22+
# (guaranteed to be unique) when there are multiple maximum values.
23+
return k[maxima[np.argmin(k[maxima])]]
2424

2525

2626
def encode_features(X, enc_map=None):

kmodes/util/dissim.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ def jaccard_dissim_binary(a, b, **__):
1717
denominator = np.sum(np.bitwise_or(a, b), axis=1)
1818
if (denominator == 0).any(0):
1919
raise ValueError("Insufficient Number of data since union is 0")
20-
else:
21-
return 1 - numerator / denominator
20+
return 1 - numerator / denominator
2221
raise ValueError("Missing or non Binary values detected in Binary columns.")
2322

2423

@@ -28,11 +27,11 @@ def jaccard_dissim_label(a, b, **__):
2827
raise ValueError("Missing values detected in Numeric columns.")
2928
intersect_len = np.empty(len(a), dtype=int)
3029
union_len = np.empty(len(a), dtype=int)
31-
i = 0
30+
ii = 0
3231
for row in a:
33-
intersect_len[i] = len(np.intersect1d(row, b))
34-
union_len[i] = len(np.unique(row)) + len(np.unique(b)) - intersect_len[i]
35-
i += 1
32+
intersect_len[ii] = len(np.intersect1d(row, b))
33+
union_len[ii] = len(np.unique(row)) + len(np.unique(b)) - intersect_len[ii]
34+
ii += 1
3635
if (union_len == 0).any():
3736
raise ValueError("Insufficient Number of data since union is 0")
3837
return 1 - intersect_len / union_len

kmodes/util/tests/test_dissim.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from kmodes.util.dissim import jaccard_dissim_binary, jaccard_dissim_label
1212

1313

14-
# pylint: disable=R0201,W0105
14+
# pylint: disable=no-self-use,pointless-statement
1515
class TestDissimilarityMeasures(unittest.TestCase):
1616

1717
def test_matching_dissim(self):

kmodes/util/tests/test_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
])
4343

4444

45-
# pylint: disable=R0201,W0105
45+
# pylint: disable=no-self-use,pointless-statement
4646
class TestUtils(unittest.TestCase):
4747

4848
def test_get_max_value_key(self):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
VERSION = kmodes.__version__
66

7-
with open('README.rst', 'r') as readme_file:
7+
with open('README.rst', encoding='utf8') as readme_file:
88
README = readme_file.read()
99

1010
setup(

0 commit comments

Comments
 (0)