Skip to content

Commit

Permalink
Enable ruff RUF003 rule (TheAlgorithms#11376)
Browse files Browse the repository at this point in the history
* Enable ruff RUF003 rule

* Update pyproject.toml

---------

Co-authored-by: Christian Clauss <[email protected]>
  • Loading branch information
MaximSmolskiy and cclauss committed Apr 22, 2024
1 parent 4700297 commit d016fda
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dynamic_programming/fast_fibonacci.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _fib(n: int) -> tuple[int, int]:
if n == 0: # (F(0), F(1))
return (0, 1)

# F(2n) = F(n)[2F(n+1) F(n)]
# F(2n) = F(n)[2F(n+1) - F(n)]
# F(2n+1) = F(n+1)^2+F(n)^2
a, b = _fib(n // 2)
c = a * (b * 2 - a)
Expand Down
4 changes: 2 additions & 2 deletions graphs/ant_colony_optimization_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def main(
pheromone_evaporation: float,
alpha: float,
beta: float,
q: float, # Pheromone system parameters Qwhich is a constant
q: float, # Pheromone system parameters Q, which is a constant
) -> tuple[list[int], float]:
"""
Ant colony algorithm main function
Expand Down Expand Up @@ -117,7 +117,7 @@ def pheromone_update(
cities: dict[int, list[int]],
pheromone_evaporation: float,
ants_route: list[list[int]],
q: float, # Pheromone system parameters Qwhich is a constant
q: float, # Pheromone system parameters Q, which is a constant
best_path: list[int],
best_distance: float,
) -> tuple[list[list[float]], list[int], float]:
Expand Down
2 changes: 1 addition & 1 deletion machine_learning/polynomial_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def fit(self, x_train: np.ndarray, y_train: np.ndarray) -> None:
"Design matrix is not full rank, can't compute coefficients"
)

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

def predict(self, data: np.ndarray) -> np.ndarray:
Expand Down
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ lint.ignore = [ # `ruff rule S101` for a description of that rule
"PLW2901", # PLW2901: Redefined loop variable -- FIX ME
"PT011", # `pytest.raises(Exception)` is too broad, set the `match` parameter or use a more specific exception
"PT018", # Assertion should be broken down into multiple parts
"RUF001", # String contains ambiguous {}. Did you mean {}?
"RUF002", # Docstring contains ambiguous {}. Did you mean {}?
"RUF003", # Comment contains ambiguous {}. Did you mean {}?
"S101", # Use of `assert` detected -- DO NOT FIX
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes -- FIX ME
"SLF001", # Private member accessed: `_Iterator` -- FIX ME
Expand Down
2 changes: 1 addition & 1 deletion strings/credit_card_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def luhn_validation(credit_card_number: str) -> bool:
digit = int(cc_number[i])
digit *= 2
# If doubling of a number results in a two digit number
# i.e greater than 9(e.g., 6 × 2 = 12),
# i.e greater than 9(e.g., 6 x 2 = 12),
# then add the digits of the product (e.g., 12: 1 + 2 = 3, 15: 1 + 5 = 6),
# to get a single digit number.
if digit > 9:
Expand Down

0 comments on commit d016fda

Please sign in to comment.