Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 20, 2025
1 parent ff8e76d commit ecddeed
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cs/algorithms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"breadth_first_search",
"bubble_sort",
"bucket_sort",
"build_suffix_array",
"build_optimal_bst",
"build_suffix_array",
"connected_components",
"depth_first_search",
"dfs_traversal",
Expand Down
6 changes: 2 additions & 4 deletions cs/algorithms/string/sais.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,8 @@ def get_suffix_annotations(text: list[int]) -> tuple[list[SuffixType], list[int]
lms_suffixes: list[int] = []
suffix_marks = [SuffixType.S] * len(text)
for k in range(len(text) - 1, 0, -1):
if (
text[k - 1] > text[k]
or text[k - 1] == text[k]
and suffix_marks[k] is SuffixType.L
if text[k - 1] > text[k] or (
text[k - 1] == text[k] and suffix_marks[k] is SuffixType.L
):
suffix_marks[k - 1] = SuffixType.L
if suffix_marks[k] is SuffixType.S:
Expand Down
2 changes: 1 addition & 1 deletion cs/structures/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from .trie import Trie

__all__ = (
"RMQ",
"ApproxDistanceOracle",
"ApproxFiniteMetricOracle",
"BinaryHeap",
Expand All @@ -53,7 +54,6 @@
"Node",
"PrecomputedRMQ",
"Queue",
"RMQ",
"RedBlackTree",
"RedBlackTreeNode",
"RobinHood",
Expand Down
3 changes: 1 addition & 2 deletions cs/structures/heap/fibonacci_heap.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,7 @@ def dequeue(self) -> tuple[T, float]:
# reparent operation that merged two different trees of equal
# priority, we need to make sure that the min pointer points to
# the root-level one.
if curr <= self.top:
self.top = curr
self.top = min(self.top, curr)
if not self.allow_duplicates:
del self.elem_to_entry[min_elem.value]
return return_val
Expand Down
8 changes: 5 additions & 3 deletions cs/structures/tree/red_black_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,11 @@ def _check_coloring(node: RedBlackTreeNode[T] | None) -> bool:
"""
return node is None or (
node.color is Color.BLACK
or self.color(node.left) is self.color(node.right) is Color.BLACK
and _check_coloring(node.left)
and _check_coloring(node.right)
or (
self.color(node.left) is self.color(node.right) is Color.BLACK
and _check_coloring(node.left)
and _check_coloring(node.right)
)
)

def _black_height(node: RedBlackTreeNode[T] | None) -> int:
Expand Down
4 changes: 2 additions & 2 deletions explore/rmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def construct_rmq(rmq_type: str, data: list[int]) -> RMQ:
def print_arr_with_index(data: list[int], low: int) -> str:
result = f"\nIndex | Data\n{'-' * 15}\n"
for i, value in enumerate(data):
result += f"{low+i if low else i:5d} | {value}\n"
result += f"{low + i if low else i:5d} | {value}\n"
return result


Expand Down Expand Up @@ -71,7 +71,7 @@ def run_tests(minimum: int, maximum: int, num_builds: int, num_queries: int) ->
assert data[ours] == data[theirs], (
"Error: query produced the wrong answer:\n\n"
f"Query: Low: {low}, High: {high}\n"
f"{print_arr_with_index(data[low: high], low)}\n"
f"{print_arr_with_index(data[low:high], low)}\n"
f"Solution Index: {ours}, Your Index: {theirs}\n\n"
f"Val at index {ours}: {data[ours]}, "
f"Val at index {theirs}: {data[theirs]}"
Expand Down
2 changes: 1 addition & 1 deletion utils/ruff_ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def main() -> None:
error_messages[error_code] = error_message
for error_code, error_message in sorted(error_messages.items()):
spaces = 8 - len(error_code)
print(f'"{error_code}",{' ' * spaces}# {error_message}')
print(f'"{error_code}",{" " * spaces}# {error_message}')


def extract_details(ruff_error_line: str) -> tuple[Path, int, int, str]:
Expand Down

0 comments on commit ecddeed

Please sign in to comment.