Skip to content

Commit 004f2fa

Browse files
committed
Fixes unsed variable errors in LGTM
1 parent 80718bd commit 004f2fa

File tree

6 files changed

+13
-30
lines changed

6 files changed

+13
-30
lines changed

ciphers/mixed_keyword_cypher.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ def mixed_keyword(key="college", pt="UNIVERSITY"):
2929
# print(temp)
3030
alpha = []
3131
modalpha = []
32-
# modalpha.append(temp)
33-
dic = dict()
34-
c = 0
3532
for i in range(65, 91):
3633
t = chr(i)
3734
alpha.append(t)

data_structures/binary_tree/binary_search_tree.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ def remove(self, value):
112112
if node is not None:
113113
if node.left is None and node.right is None: # If it has no children
114114
self.__reassign_nodes(node, None)
115-
node = None
116115
elif node.left is None: # Has only right children
117116
self.__reassign_nodes(node, node.right)
118117
elif node.right is None: # Has only left children
@@ -172,7 +171,7 @@ def binary_search_tree():
172171
>>> BinarySearchTree().search(6)
173172
Traceback (most recent call last):
174173
...
175-
IndexError: Warning: Tree is empty! please use another.
174+
IndexError: Warning: Tree is empty! please use another.
176175
"""
177176
testlist = (8, 3, 6, 1, 10, 14, 13, 4, 7)
178177
t = BinarySearchTree()
@@ -201,8 +200,6 @@ def binary_search_tree():
201200
print(t)
202201

203202

204-
二叉搜索树 = binary_search_tree
205-
206203
if __name__ == "__main__":
207204
import doctest
208205

graphs/a_star.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def search(grid, init, goal, cost, heuristic):
5252

5353
while not found and not resign:
5454
if len(cell) == 0:
55-
resign = True
5655
return "FAIL"
5756
else:
5857
cell.sort() # to choose the least costliest action so as to move closer to the goal
@@ -61,7 +60,6 @@ def search(grid, init, goal, cost, heuristic):
6160
x = next[2]
6261
y = next[3]
6362
g = next[1]
64-
f = next[0]
6563

6664
if x == goal[0] and y == goal[1]:
6765
found = True

hashes/hamming_code.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@
55

66
"""
77
* This code implement the Hamming code:
8-
https://en.wikipedia.org/wiki/Hamming_code - In telecommunication,
8+
https://en.wikipedia.org/wiki/Hamming_code - In telecommunication,
99
Hamming codes are a family of linear error-correcting codes. Hamming
10-
codes can detect up to two-bit errors or correct one-bit errors
11-
without detection of uncorrected errors. By contrast, the simple
12-
parity code cannot correct errors, and can detect only an odd number
13-
of bits in error. Hamming codes are perfect codes, that is, they
14-
achieve the highest possible rate for codes with their block length
10+
codes can detect up to two-bit errors or correct one-bit errors
11+
without detection of uncorrected errors. By contrast, the simple
12+
parity code cannot correct errors, and can detect only an odd number
13+
of bits in error. Hamming codes are perfect codes, that is, they
14+
achieve the highest possible rate for codes with their block length
1515
and minimum distance of three.
1616
1717
* the implemented code consists of:
1818
* a function responsible for encoding the message (emitterConverter)
1919
* return the encoded message
2020
* a function responsible for decoding the message (receptorConverter)
2121
* return the decoded message and a ack of data integrity
22-
22+
2323
* how to use:
24-
to be used you must declare how many parity bits (sizePari)
24+
to be used you must declare how many parity bits (sizePari)
2525
you want to include in the message.
2626
it is desired (for test purposes) to select a bit to be set
2727
as an error. This serves to check whether the code is working correctly.
28-
Lastly, the variable of the message/word that must be desired to be
28+
Lastly, the variable of the message/word that must be desired to be
2929
encoded (text).
30-
30+
3131
* how this work:
3232
declaration of variables (sizePari, be, text)
3333
@@ -71,7 +71,7 @@ def emitterConverter(sizePar, data):
7171
"""
7272
:param sizePar: how many parity bits the message must have
7373
:param data: information bits
74-
:return: message to be transmitted by unreliable medium
74+
:return: message to be transmitted by unreliable medium
7575
- bits of information merged with parity bits
7676
7777
>>> emitterConverter(4, "101010111111")
@@ -84,7 +84,6 @@ def emitterConverter(sizePar, data):
8484
dataOut = []
8585
parity = []
8686
binPos = [bin(x)[2:] for x in range(1, sizePar + len(data) + 1)]
87-
pos = [x for x in range(1, sizePar + len(data) + 1)]
8887

8988
# sorted information data for the size of the output data
9089
dataOrd = []
@@ -188,7 +187,6 @@ def receptorConverter(sizePar, data):
188187
dataOut = []
189188
parity = []
190189
binPos = [bin(x)[2:] for x in range(1, sizePar + len(dataOutput) + 1)]
191-
pos = [x for x in range(1, sizePar + len(dataOutput) + 1)]
192190

193191
# sorted information data for the size of the output data
194192
dataOrd = []

linear_algebra/src/polynom-for-points.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ def points_to_polynomial(coordinates):
6868
# put the y values into a vector
6969
vector = []
7070
while count_of_line < x:
71-
count_in_line = 0
7271
vector.append(coordinates[count_of_line][1])
7372
count_of_line += 1
7473

matrix/matrix_operation.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,7 @@ def inverse(matrix):
111111

112112

113113
def _check_not_integer(matrix):
114-
try:
115-
rows = len(matrix)
116-
cols = len(matrix[0])
117-
return True
118-
except TypeError:
119-
raise TypeError("Cannot input an integer value, it must be a matrix")
120-
114+
return not isinstance(matrix, int) and not isinstance(matrix[0], int)
121115

122116
def _shape(matrix):
123117
return list((len(matrix), len(matrix[0])))

0 commit comments

Comments
 (0)