Skip to content

Commit 45d63c5

Browse files
committed
fixes to appease new flake8 plugins
1 parent 4c5dd99 commit 45d63c5

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

abydos/distance/_typo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ def _get_char_coord(char, kb_array):
279279
for row in kb_array: # pragma: no branch
280280
if char in row:
281281
return kb_array.index(row), row.index(char)
282+
return -1, -1
282283

283284
def _euclidean_keyboard_distance(char1, char2):
284285
row1, col1 = _get_char_coord(char1, _kb_array_for_char(char1))

abydos/phones/_phones.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -961,19 +961,8 @@ def cmp_features(feat1, feat2, weights=None):
961961

962962
magnitude = sum(weights) if weights else len(_FEATURE_MASK)
963963

964-
featxor = feat1 ^ feat2
965-
diffbits = 0
966-
i = 0
967-
while featxor:
968-
if featxor & 0b1:
969-
diffbits += weights[i] if weights else 1
970-
featxor >>= 1
971-
if featxor & 0b1:
972-
diffbits += weights[i] if weights else 1
973-
featxor >>= 1
974-
i += 1
975-
return 1 - (0 if not diffbits else (diffbits / (2 * magnitude)))
976964
"""
965+
# Alternate implementation
977966
diff_feats = 0
978967
i = 0
979968
while feat1 or feat2:
@@ -990,6 +979,19 @@ def cmp_features(feat1, feat2, weights=None):
990979
return 1 - (diff_feats / magnitude)
991980
"""
992981

982+
featxor = feat1 ^ feat2
983+
diffbits = 0
984+
i = 0
985+
while featxor:
986+
if featxor & 0b1:
987+
diffbits += weights[i] if weights else 1
988+
featxor >>= 1
989+
if featxor & 0b1:
990+
diffbits += weights[i] if weights else 1
991+
featxor >>= 1
992+
i += 1
993+
return 1 - (0 if not diffbits else (diffbits / (2 * magnitude)))
994+
993995

994996
if __name__ == '__main__':
995997
import doctest

abydos/util/_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def _default_download_dir():
179179
"""
180180
# Check if we are on GAE where we cannot write into filesystem.
181181
if 'APPENGINE_RUNTIME' in os.environ: # pragma: no cover
182-
return
182+
return None
183183

184184
# Check if we have sufficient permissions to install in a
185185
# variety of system-wide locations.

data/features/features_csv_to_dict.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ def binarize(num):
8181
return '10'
8282
elif num == '1': # +
8383
return '01'
84-
elif num == '2': # ± (segmental) or copy from base (non-segmental)
85-
return '11'
84+
# '2' -> ± (segmental) or copy from base (non-segmental)
85+
return '11'
8686

8787
def init_termdicts():
8888
"""Initialize the terms dict.

0 commit comments

Comments
 (0)