pre-commit autoupdate 2025-09-11 (#12963)
* pre-commit autoupdate 2025-09-11 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -16,7 +16,7 @@ repos:
|
|||||||
- id: auto-walrus
|
- id: auto-walrus
|
||||||
|
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.12.12
|
rev: v0.13.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff-check
|
- id: ruff-check
|
||||||
- id: ruff-format
|
- id: ruff-format
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ def search(values):
|
|||||||
if all(len(values[s]) == 1 for s in squares):
|
if all(len(values[s]) == 1 for s in squares):
|
||||||
return values ## Solved!
|
return values ## Solved!
|
||||||
## Chose the unfilled square s with the fewest possibilities
|
## Chose the unfilled square s with the fewest possibilities
|
||||||
n, s = min((len(values[s]), s) for s in squares if len(values[s]) > 1)
|
_n, s = min((len(values[s]), s) for s in squares if len(values[s]) > 1)
|
||||||
return some(search(assign(values.copy(), s, d)) for d in values[s])
|
return some(search(assign(values.copy(), s, d)) for d in values[s])
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class RadixNode:
|
|||||||
if not incoming_node:
|
if not incoming_node:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
matching_string, remaining_prefix, remaining_word = incoming_node.match(
|
_matching_string, remaining_prefix, remaining_word = incoming_node.match(
|
||||||
word
|
word
|
||||||
)
|
)
|
||||||
# If there is remaining prefix, the word can't be on the tree
|
# If there is remaining prefix, the word can't be on the tree
|
||||||
@@ -144,7 +144,7 @@ class RadixNode:
|
|||||||
if not incoming_node:
|
if not incoming_node:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
matching_string, remaining_prefix, remaining_word = incoming_node.match(
|
_matching_string, remaining_prefix, remaining_word = incoming_node.match(
|
||||||
word
|
word
|
||||||
)
|
)
|
||||||
# If there is remaining prefix, the word can't be on the tree
|
# If there is remaining prefix, the word can't be on the tree
|
||||||
|
|||||||
@@ -448,7 +448,7 @@ class TestGraphAdjacencyList(unittest.TestCase):
|
|||||||
(
|
(
|
||||||
undirected_graph,
|
undirected_graph,
|
||||||
directed_graph,
|
directed_graph,
|
||||||
random_vertices,
|
_random_vertices,
|
||||||
random_edges,
|
random_edges,
|
||||||
) = self.__generate_graphs(20, 0, 100, 4)
|
) = self.__generate_graphs(20, 0, 100, 4)
|
||||||
|
|
||||||
@@ -502,7 +502,7 @@ class TestGraphAdjacencyList(unittest.TestCase):
|
|||||||
undirected_graph,
|
undirected_graph,
|
||||||
directed_graph,
|
directed_graph,
|
||||||
random_vertices,
|
random_vertices,
|
||||||
random_edges,
|
_random_edges,
|
||||||
) = self.__generate_graphs(20, 0, 100, 4)
|
) = self.__generate_graphs(20, 0, 100, 4)
|
||||||
|
|
||||||
for vertex in random_vertices:
|
for vertex in random_vertices:
|
||||||
@@ -516,7 +516,7 @@ class TestGraphAdjacencyList(unittest.TestCase):
|
|||||||
undirected_graph,
|
undirected_graph,
|
||||||
directed_graph,
|
directed_graph,
|
||||||
random_vertices,
|
random_vertices,
|
||||||
random_edges,
|
_random_edges,
|
||||||
) = self.__generate_graphs(20, 0, 100, 4)
|
) = self.__generate_graphs(20, 0, 100, 4)
|
||||||
|
|
||||||
for i in range(101):
|
for i in range(101):
|
||||||
@@ -530,7 +530,7 @@ class TestGraphAdjacencyList(unittest.TestCase):
|
|||||||
(
|
(
|
||||||
undirected_graph,
|
undirected_graph,
|
||||||
directed_graph,
|
directed_graph,
|
||||||
random_vertices,
|
_random_vertices,
|
||||||
random_edges,
|
random_edges,
|
||||||
) = self.__generate_graphs(20, 0, 100, 4)
|
) = self.__generate_graphs(20, 0, 100, 4)
|
||||||
|
|
||||||
@@ -569,7 +569,7 @@ class TestGraphAdjacencyList(unittest.TestCase):
|
|||||||
undirected_graph,
|
undirected_graph,
|
||||||
directed_graph,
|
directed_graph,
|
||||||
random_vertices,
|
random_vertices,
|
||||||
random_edges,
|
_random_edges,
|
||||||
) = self.__generate_graphs(20, 0, 100, 4)
|
) = self.__generate_graphs(20, 0, 100, 4)
|
||||||
|
|
||||||
for vertex in random_vertices:
|
for vertex in random_vertices:
|
||||||
|
|||||||
@@ -469,7 +469,7 @@ class TestGraphMatrix(unittest.TestCase):
|
|||||||
(
|
(
|
||||||
undirected_graph,
|
undirected_graph,
|
||||||
directed_graph,
|
directed_graph,
|
||||||
random_vertices,
|
_random_vertices,
|
||||||
random_edges,
|
random_edges,
|
||||||
) = self.__generate_graphs(20, 0, 100, 4)
|
) = self.__generate_graphs(20, 0, 100, 4)
|
||||||
|
|
||||||
@@ -523,7 +523,7 @@ class TestGraphMatrix(unittest.TestCase):
|
|||||||
undirected_graph,
|
undirected_graph,
|
||||||
directed_graph,
|
directed_graph,
|
||||||
random_vertices,
|
random_vertices,
|
||||||
random_edges,
|
_random_edges,
|
||||||
) = self.__generate_graphs(20, 0, 100, 4)
|
) = self.__generate_graphs(20, 0, 100, 4)
|
||||||
|
|
||||||
for vertex in random_vertices:
|
for vertex in random_vertices:
|
||||||
@@ -537,7 +537,7 @@ class TestGraphMatrix(unittest.TestCase):
|
|||||||
undirected_graph,
|
undirected_graph,
|
||||||
directed_graph,
|
directed_graph,
|
||||||
random_vertices,
|
random_vertices,
|
||||||
random_edges,
|
_random_edges,
|
||||||
) = self.__generate_graphs(20, 0, 100, 4)
|
) = self.__generate_graphs(20, 0, 100, 4)
|
||||||
|
|
||||||
for i in range(101):
|
for i in range(101):
|
||||||
@@ -551,7 +551,7 @@ class TestGraphMatrix(unittest.TestCase):
|
|||||||
(
|
(
|
||||||
undirected_graph,
|
undirected_graph,
|
||||||
directed_graph,
|
directed_graph,
|
||||||
random_vertices,
|
_random_vertices,
|
||||||
random_edges,
|
random_edges,
|
||||||
) = self.__generate_graphs(20, 0, 100, 4)
|
) = self.__generate_graphs(20, 0, 100, 4)
|
||||||
|
|
||||||
@@ -590,7 +590,7 @@ class TestGraphMatrix(unittest.TestCase):
|
|||||||
undirected_graph,
|
undirected_graph,
|
||||||
directed_graph,
|
directed_graph,
|
||||||
random_vertices,
|
random_vertices,
|
||||||
random_edges,
|
_random_edges,
|
||||||
) = self.__generate_graphs(20, 0, 100, 4)
|
) = self.__generate_graphs(20, 0, 100, 4)
|
||||||
|
|
||||||
for vertex in random_vertices:
|
for vertex in random_vertices:
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class TestClass(unittest.TestCase):
|
|||||||
# profit = [10, 20, 30, 40, 50, 60]
|
# profit = [10, 20, 30, 40, 50, 60]
|
||||||
# weight = [2, 4, 6, 8, 10, 12]
|
# weight = [2, 4, 6, 8, 10, 12]
|
||||||
# max_weight = -15
|
# max_weight = -15
|
||||||
pytest.raises(ValueError, match="max_weight must greater than zero.")
|
pytest.raises(ValueError, match=r"max_weight must greater than zero.")
|
||||||
|
|
||||||
def test_negative_profit_value(self):
|
def test_negative_profit_value(self):
|
||||||
"""
|
"""
|
||||||
@@ -38,7 +38,7 @@ class TestClass(unittest.TestCase):
|
|||||||
# profit = [10, -20, 30, 40, 50, 60]
|
# profit = [10, -20, 30, 40, 50, 60]
|
||||||
# weight = [2, 4, 6, 8, 10, 12]
|
# weight = [2, 4, 6, 8, 10, 12]
|
||||||
# max_weight = 15
|
# max_weight = 15
|
||||||
pytest.raises(ValueError, match="Weight can not be negative.")
|
pytest.raises(ValueError, match=r"Weight can not be negative.")
|
||||||
|
|
||||||
def test_negative_weight_value(self):
|
def test_negative_weight_value(self):
|
||||||
"""
|
"""
|
||||||
@@ -48,7 +48,7 @@ class TestClass(unittest.TestCase):
|
|||||||
# profit = [10, 20, 30, 40, 50, 60]
|
# profit = [10, 20, 30, 40, 50, 60]
|
||||||
# weight = [2, -4, 6, -8, 10, 12]
|
# weight = [2, -4, 6, -8, 10, 12]
|
||||||
# max_weight = 15
|
# max_weight = 15
|
||||||
pytest.raises(ValueError, match="Profit can not be negative.")
|
pytest.raises(ValueError, match=r"Profit can not be negative.")
|
||||||
|
|
||||||
def test_null_max_weight(self):
|
def test_null_max_weight(self):
|
||||||
"""
|
"""
|
||||||
@@ -58,7 +58,7 @@ class TestClass(unittest.TestCase):
|
|||||||
# profit = [10, 20, 30, 40, 50, 60]
|
# profit = [10, 20, 30, 40, 50, 60]
|
||||||
# weight = [2, 4, 6, 8, 10, 12]
|
# weight = [2, 4, 6, 8, 10, 12]
|
||||||
# max_weight = null
|
# max_weight = null
|
||||||
pytest.raises(ValueError, match="max_weight must greater than zero.")
|
pytest.raises(ValueError, match=r"max_weight must greater than zero.")
|
||||||
|
|
||||||
def test_unequal_list_length(self):
|
def test_unequal_list_length(self):
|
||||||
"""
|
"""
|
||||||
@@ -68,7 +68,9 @@ class TestClass(unittest.TestCase):
|
|||||||
# profit = [10, 20, 30, 40, 50]
|
# profit = [10, 20, 30, 40, 50]
|
||||||
# weight = [2, 4, 6, 8, 10, 12]
|
# weight = [2, 4, 6, 8, 10, 12]
|
||||||
# max_weight = 100
|
# max_weight = 100
|
||||||
pytest.raises(IndexError, match="The length of profit and weight must be same.")
|
pytest.raises(
|
||||||
|
IndexError, match=r"The length of profit and weight must be same."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ def retroactive_resolution(
|
|||||||
[ 0.5]])
|
[ 0.5]])
|
||||||
"""
|
"""
|
||||||
|
|
||||||
rows, columns = np.shape(coefficients)
|
rows, _columns = np.shape(coefficients)
|
||||||
|
|
||||||
x: NDArray[float64] = np.zeros((rows, 1), dtype=float)
|
x: NDArray[float64] = np.zeros((rows, 1), dtype=float)
|
||||||
for row in reversed(range(rows)):
|
for row in reversed(range(rows)):
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ def jacobi_iteration_method(
|
|||||||
(coefficient_matrix, constant_matrix), axis=1
|
(coefficient_matrix, constant_matrix), axis=1
|
||||||
)
|
)
|
||||||
|
|
||||||
rows, cols = table.shape
|
rows, _cols = table.shape
|
||||||
|
|
||||||
strictly_diagonally_dominant(table)
|
strictly_diagonally_dominant(table)
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ def jacobi_iteration_method(
|
|||||||
|
|
||||||
# Here we get 'i_col' - these are the column numbers, for each row
|
# Here we get 'i_col' - these are the column numbers, for each row
|
||||||
# without diagonal elements, except for the last column.
|
# without diagonal elements, except for the last column.
|
||||||
i_row, i_col = np.where(masks)
|
_i_row, i_col = np.where(masks)
|
||||||
ind = i_col.reshape(-1, rows - 1)
|
ind = i_col.reshape(-1, rows - 1)
|
||||||
|
|
||||||
#'i_col' is converted to a two-dimensional list 'ind', which will be
|
#'i_col' is converted to a two-dimensional list 'ind', which will be
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class PolynomialRegression:
|
|||||||
...
|
...
|
||||||
ValueError: Data must have dimensions N x 1
|
ValueError: Data must have dimensions N x 1
|
||||||
"""
|
"""
|
||||||
rows, *remaining = data.shape
|
_rows, *remaining = data.shape
|
||||||
if remaining:
|
if remaining:
|
||||||
raise ValueError("Data must have dimensions N x 1")
|
raise ValueError("Data must have dimensions N x 1")
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ def main() -> None:
|
|||||||
"""
|
"""
|
||||||
Driver function to execute PCA and display results.
|
Driver function to execute PCA and display results.
|
||||||
"""
|
"""
|
||||||
data_x, data_y = collect_dataset()
|
data_x, _data_y = collect_dataset()
|
||||||
|
|
||||||
# Number of principal components to retain
|
# Number of principal components to retain
|
||||||
n_components = 2
|
n_components = 2
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ def invert_modulo(a: int, n: int) -> int:
|
|||||||
1
|
1
|
||||||
|
|
||||||
"""
|
"""
|
||||||
(b, x) = extended_euclid(a, n)
|
(b, _x) = extended_euclid(a, n)
|
||||||
if b < 0:
|
if b < 0:
|
||||||
b = (b % n + n) % n
|
b = (b % n + n) % n
|
||||||
return b
|
return b
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ def modular_division(a: int, b: int, n: int) -> int:
|
|||||||
assert n > 1
|
assert n > 1
|
||||||
assert a > 0
|
assert a > 0
|
||||||
assert greatest_common_divisor(a, n) == 1
|
assert greatest_common_divisor(a, n) == 1
|
||||||
(d, t, s) = extended_gcd(n, a) # Implemented below
|
(_d, _t, s) = extended_gcd(n, a) # Implemented below
|
||||||
x = (b * s) % n
|
x = (b * s) % n
|
||||||
return x
|
return x
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ def invert_modulo(a: int, n: int) -> int:
|
|||||||
1
|
1
|
||||||
|
|
||||||
"""
|
"""
|
||||||
(b, x) = extended_euclid(a, n) # Implemented below
|
(b, _x) = extended_euclid(a, n) # Implemented below
|
||||||
if b < 0:
|
if b < 0:
|
||||||
b = (b % n + n) % n
|
b = (b % n + n) % n
|
||||||
return b
|
return b
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ class CNN:
|
|||||||
print((" - - Shape: Test_Data ", np.shape(datas_test)))
|
print((" - - Shape: Test_Data ", np.shape(datas_test)))
|
||||||
for p in range(len(datas_test)):
|
for p in range(len(datas_test)):
|
||||||
data_test = np.asmatrix(datas_test[p])
|
data_test = np.asmatrix(datas_test[p])
|
||||||
data_focus1, data_conved1 = self.convolute(
|
_data_focus1, data_conved1 = self.convolute(
|
||||||
data_test,
|
data_test,
|
||||||
self.conv1,
|
self.conv1,
|
||||||
self.w_conv1,
|
self.w_conv1,
|
||||||
@@ -339,7 +339,7 @@ class CNN:
|
|||||||
def convolution(self, data):
|
def convolution(self, data):
|
||||||
# return the data of image after convoluting process so we can check it out
|
# return the data of image after convoluting process so we can check it out
|
||||||
data_test = np.asmatrix(data)
|
data_test = np.asmatrix(data)
|
||||||
data_focus1, data_conved1 = self.convolute(
|
_data_focus1, data_conved1 = self.convolute(
|
||||||
data_test,
|
data_test,
|
||||||
self.conv1,
|
self.conv1,
|
||||||
self.w_conv1,
|
self.w_conv1,
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ def solution(n: int = 10**15) -> int:
|
|||||||
i = 1
|
i = 1
|
||||||
dn = 0
|
dn = 0
|
||||||
while True:
|
while True:
|
||||||
diff, terms_jumped = next_term(digits, 20, i + dn, n)
|
_diff, terms_jumped = next_term(digits, 20, i + dn, n)
|
||||||
dn += terms_jumped
|
dn += terms_jumped
|
||||||
if dn == n - i:
|
if dn == n - i:
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -124,7 +124,6 @@ lint.ignore = [
|
|||||||
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes -- FIX ME
|
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes -- FIX ME
|
||||||
"SIM905", # Consider using a list literal instead of `str.split` -- DO NOT FIX
|
"SIM905", # Consider using a list literal instead of `str.split` -- DO NOT FIX
|
||||||
"SLF001", # Private member accessed: `_Iterator` -- FIX ME
|
"SLF001", # Private member accessed: `_Iterator` -- FIX ME
|
||||||
"UP038", # Use `X | Y` in `{}` call instead of `(X, Y)` -- DO NOT FIX
|
|
||||||
]
|
]
|
||||||
|
|
||||||
lint.per-file-ignores."data_structures/hashing/tests/test_hash_map.py" = [
|
lint.per-file-ignores."data_structures/hashing/tests/test_hash_map.py" = [
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ class MLFQ:
|
|||||||
|
|
||||||
# all queues except last one have round_robin algorithm
|
# all queues except last one have round_robin algorithm
|
||||||
for i in range(self.number_of_queues - 1):
|
for i in range(self.number_of_queues - 1):
|
||||||
finished, self.ready_queue = self.round_robin(
|
_finished, self.ready_queue = self.round_robin(
|
||||||
self.ready_queue, self.time_slices[i]
|
self.ready_queue, self.time_slices[i]
|
||||||
)
|
)
|
||||||
# the last queue has first_come_first_served algorithm
|
# the last queue has first_come_first_served algorithm
|
||||||
|
|||||||
Reference in New Issue
Block a user