Skip to content

Commit d016fda

Browse files
Enable ruff RUF003 rule (TheAlgorithms#11376)
* Enable ruff RUF003 rule * Update pyproject.toml --------- Co-authored-by: Christian Clauss <[email protected]>
1 parent 4700297 commit d016fda

File tree

5 files changed

+5
-8
lines changed

5 files changed

+5
-8
lines changed

dynamic_programming/fast_fibonacci.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def _fib(n: int) -> tuple[int, int]:
2626
if n == 0: # (F(0), F(1))
2727
return (0, 1)
2828

29-
# F(2n) = F(n)[2F(n+1) F(n)]
29+
# F(2n) = F(n)[2F(n+1) - F(n)]
3030
# F(2n+1) = F(n+1)^2+F(n)^2
3131
a, b = _fib(n // 2)
3232
c = a * (b * 2 - a)

graphs/ant_colony_optimization_algorithms.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def main(
3333
pheromone_evaporation: float,
3434
alpha: float,
3535
beta: float,
36-
q: float, # Pheromone system parameters Qwhich is a constant
36+
q: float, # Pheromone system parameters Q, which is a constant
3737
) -> tuple[list[int], float]:
3838
"""
3939
Ant colony algorithm main function
@@ -117,7 +117,7 @@ def pheromone_update(
117117
cities: dict[int, list[int]],
118118
pheromone_evaporation: float,
119119
ants_route: list[list[int]],
120-
q: float, # Pheromone system parameters Qwhich is a constant
120+
q: float, # Pheromone system parameters Q, which is a constant
121121
best_path: list[int],
122122
best_distance: float,
123123
) -> tuple[list[list[float]], list[int], float]:

machine_learning/polynomial_regression.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def fit(self, x_train: np.ndarray, y_train: np.ndarray) -> None:
146146
"Design matrix is not full rank, can't compute coefficients"
147147
)
148148

149-
# np.linalg.pinv() computes the MoorePenrose pseudoinverse using SVD
149+
# np.linalg.pinv() computes the Moore-Penrose pseudoinverse using SVD
150150
self.params = np.linalg.pinv(X) @ y_train
151151

152152
def predict(self, data: np.ndarray) -> np.ndarray:

pyproject.toml

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ lint.ignore = [ # `ruff rule S101` for a description of that rule
1010
"PLW2901", # PLW2901: Redefined loop variable -- FIX ME
1111
"PT011", # `pytest.raises(Exception)` is too broad, set the `match` parameter or use a more specific exception
1212
"PT018", # Assertion should be broken down into multiple parts
13-
"RUF001", # String contains ambiguous {}. Did you mean {}?
14-
"RUF002", # Docstring contains ambiguous {}. Did you mean {}?
15-
"RUF003", # Comment contains ambiguous {}. Did you mean {}?
1613
"S101", # Use of `assert` detected -- DO NOT FIX
1714
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes -- FIX ME
1815
"SLF001", # Private member accessed: `_Iterator` -- FIX ME

strings/credit_card_validator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def luhn_validation(credit_card_number: str) -> bool:
3636
digit = int(cc_number[i])
3737
digit *= 2
3838
# If doubling of a number results in a two digit number
39-
# i.e greater than 9(e.g., 6 × 2 = 12),
39+
# i.e greater than 9(e.g., 6 x 2 = 12),
4040
# then add the digits of the product (e.g., 12: 1 + 2 = 3, 15: 1 + 5 = 6),
4141
# to get a single digit number.
4242
if digit > 9:

0 commit comments

Comments
 (0)