mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-12-18 17:20:16 +00:00
Merge branch 'master' of https://github.com/MaximSmolskiy/Python
This commit is contained in:
commit
4b560a4921
|
@ -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.4.2
|
rev: v0.4.3
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
- id: ruff-format
|
- id: ruff-format
|
||||||
|
|
|
@ -39,9 +39,7 @@ def split(root: Node | None, value: int) -> tuple[Node | None, Node | None]:
|
||||||
Left tree contains all values less than split value.
|
Left tree contains all values less than split value.
|
||||||
Right tree contains all values greater or equal, than split value
|
Right tree contains all values greater or equal, than split value
|
||||||
"""
|
"""
|
||||||
if root is None: # None tree is split into 2 Nones
|
if root is None or root.value is None: # None tree is split into 2 Nones
|
||||||
return None, None
|
|
||||||
elif root.value is None:
|
|
||||||
return None, None
|
return None, None
|
||||||
elif value < root.value:
|
elif value < root.value:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -38,7 +38,7 @@ class BinaryHeap:
|
||||||
def __swap_down(self, i: int) -> None:
|
def __swap_down(self, i: int) -> None:
|
||||||
"""Swap the element down"""
|
"""Swap the element down"""
|
||||||
while self.__size >= 2 * i:
|
while self.__size >= 2 * i:
|
||||||
if 2 * i + 1 > self.__size:
|
if 2 * i + 1 > self.__size: # noqa: SIM114
|
||||||
bigger_child = 2 * i
|
bigger_child = 2 * i
|
||||||
elif self.__heap[2 * i] > self.__heap[2 * i + 1]:
|
elif self.__heap[2 * i] > self.__heap[2 * i + 1]:
|
||||||
bigger_child = 2 * i
|
bigger_child = 2 * i
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Heap:
|
||||||
if start > size // 2 - 1:
|
if start > size // 2 - 1:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
if 2 * start + 2 >= size:
|
if 2 * start + 2 >= size: # noqa: SIM114
|
||||||
smallest_child = 2 * start + 1
|
smallest_child = 2 * start + 1
|
||||||
elif heap[2 * start + 1] < heap[2 * start + 2]:
|
elif heap[2 * start + 1] < heap[2 * start + 2]:
|
||||||
smallest_child = 2 * start + 1
|
smallest_child = 2 * start + 1
|
||||||
|
|
|
@ -105,7 +105,7 @@ class DecisionTree:
|
||||||
the predictor
|
the predictor
|
||||||
"""
|
"""
|
||||||
for i in range(len(x)):
|
for i in range(len(x)):
|
||||||
if len(x[:i]) < self.min_leaf_size:
|
if len(x[:i]) < self.min_leaf_size: # noqa: SIM114
|
||||||
continue
|
continue
|
||||||
elif len(x[i:]) < self.min_leaf_size:
|
elif len(x[i:]) < self.min_leaf_size:
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -65,7 +65,7 @@ class Matrix:
|
||||||
>>> a.validate_indices((0, 0))
|
>>> a.validate_indices((0, 0))
|
||||||
True
|
True
|
||||||
"""
|
"""
|
||||||
if not (isinstance(loc, (list, tuple)) and len(loc) == 2):
|
if not (isinstance(loc, (list, tuple)) and len(loc) == 2): # noqa: SIM114
|
||||||
return False
|
return False
|
||||||
elif not (0 <= loc[0] < self.row and 0 <= loc[1] < self.column):
|
elif not (0 <= loc[0] < self.row and 0 <= loc[1] < self.column):
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -77,14 +77,10 @@ max-complexity = 17 # default: 10
|
||||||
[tool.ruff.lint.per-file-ignores]
|
[tool.ruff.lint.per-file-ignores]
|
||||||
"arithmetic_analysis/newton_raphson.py" = ["PGH001"]
|
"arithmetic_analysis/newton_raphson.py" = ["PGH001"]
|
||||||
"data_structures/binary_tree/binary_search_tree_recursive.py" = ["BLE001"]
|
"data_structures/binary_tree/binary_search_tree_recursive.py" = ["BLE001"]
|
||||||
"data_structures/binary_tree/treap.py" = ["SIM114"]
|
|
||||||
"data_structures/hashing/tests/test_hash_map.py" = ["BLE001"]
|
"data_structures/hashing/tests/test_hash_map.py" = ["BLE001"]
|
||||||
"data_structures/heap/max_heap.py" = ["SIM114"]
|
|
||||||
"graphs/minimum_spanning_tree_prims.py" = ["SIM114"]
|
|
||||||
"hashes/enigma_machine.py" = ["BLE001"]
|
"hashes/enigma_machine.py" = ["BLE001"]
|
||||||
"machine_learning/decision_tree.py" = ["SIM114"]
|
|
||||||
"machine_learning/sequential_minimum_optimization.py" = ["SIM115"]
|
"machine_learning/sequential_minimum_optimization.py" = ["SIM115"]
|
||||||
"matrix/sherman_morrison.py" = ["SIM103", "SIM114"]
|
"matrix/sherman_morrison.py" = ["SIM103"]
|
||||||
"other/l*u_cache.py" = ["RUF012"]
|
"other/l*u_cache.py" = ["RUF012"]
|
||||||
"physics/newtons_second_law_of_motion.py" = ["BLE001"]
|
"physics/newtons_second_law_of_motion.py" = ["BLE001"]
|
||||||
"project_euler/problem_099/sol1.py" = ["SIM115"]
|
"project_euler/problem_099/sol1.py" = ["SIM115"]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user