refactor: Indent ... for visual purposes (#7744)

This commit is contained in:
Caeden Perelli-Harris
2022-10-27 18:42:30 +01:00
committed by GitHub
parent e8915097c4
commit 9bba42eca8
46 changed files with 134 additions and 134 deletions

View File

@@ -196,7 +196,7 @@ def binary_search_tree() -> None:
1 4 7 6 3 13 14 10 8
>>> BinarySearchTree().search(6)
Traceback (most recent call last):
...
...
IndexError: Warning: Tree is empty! please use another.
"""
testlist = (8, 3, 6, 1, 10, 14, 13, 4, 7)

View File

@@ -21,11 +21,11 @@ def binary_tree_mirror(binary_tree: dict, root: int = 1) -> dict:
{1: [3, 2], 2: [5, 4], 3: [7, 6], 4: [11, 10]}
>>> binary_tree_mirror({ 1: [2,3], 2: [4,5], 3: [6,7], 4: [10,11]}, 5)
Traceback (most recent call last):
...
...
ValueError: root 5 is not present in the binary_tree
>>> binary_tree_mirror({}, 5)
Traceback (most recent call last):
...
...
ValueError: binary tree cannot be empty
"""
if not binary_tree:

View File

@@ -67,7 +67,7 @@ def factorial(n: int) -> int:
True
>>> factorial(-5) # doctest: +ELLIPSIS
Traceback (most recent call last):
...
...
ValueError: factorial() not defined for negative values
"""
if n < 0:

View File

@@ -64,11 +64,11 @@ class DoublyLinkedList:
>>> linked_list = DoublyLinkedList()
>>> linked_list.insert_at_nth(-1, 666)
Traceback (most recent call last):
....
....
IndexError: list index out of range
>>> linked_list.insert_at_nth(1, 666)
Traceback (most recent call last):
....
....
IndexError: list index out of range
>>> linked_list.insert_at_nth(0, 2)
>>> linked_list.insert_at_nth(0, 1)
@@ -78,7 +78,7 @@ class DoublyLinkedList:
'1->2->3->4'
>>> linked_list.insert_at_nth(5, 5)
Traceback (most recent call last):
....
....
IndexError: list index out of range
"""
if not 0 <= index <= len(self):
@@ -114,7 +114,7 @@ class DoublyLinkedList:
>>> linked_list = DoublyLinkedList()
>>> linked_list.delete_at_nth(0)
Traceback (most recent call last):
....
....
IndexError: list index out of range
>>> for i in range(0, 5):
... linked_list.insert_at_nth(i, i + 1)
@@ -128,7 +128,7 @@ class DoublyLinkedList:
'2->4'
>>> linked_list.delete_at_nth(2)
Traceback (most recent call last):
....
....
IndexError: list index out of range
"""
if not 0 <= index <= len(self) - 1:

View File

@@ -95,11 +95,11 @@ class LinkedList:
True
>>> linked_list[-10]
Traceback (most recent call last):
...
...
ValueError: list index out of range.
>>> linked_list[len(linked_list)]
Traceback (most recent call last):
...
...
ValueError: list index out of range.
"""
if not 0 <= index < len(self):
@@ -122,11 +122,11 @@ class LinkedList:
-666
>>> linked_list[-10] = 666
Traceback (most recent call last):
...
...
ValueError: list index out of range.
>>> linked_list[len(linked_list)] = 666
Traceback (most recent call last):
...
...
ValueError: list index out of range.
"""
if not 0 <= index < len(self):
@@ -233,7 +233,7 @@ class LinkedList:
'third'
>>> linked_list.delete_head()
Traceback (most recent call last):
...
...
IndexError: List index out of range.
"""
return self.delete_nth(0)
@@ -260,7 +260,7 @@ class LinkedList:
'first'
>>> linked_list.delete_tail()
Traceback (most recent call last):
...
...
IndexError: List index out of range.
"""
return self.delete_nth(len(self) - 1)
@@ -281,11 +281,11 @@ class LinkedList:
first->third
>>> linked_list.delete_nth(5) # this raises error
Traceback (most recent call last):
...
...
IndexError: List index out of range.
>>> linked_list.delete_nth(-1) # this also raises error
Traceback (most recent call last):
...
...
IndexError: List index out of range.
"""
if not 0 <= index <= len(self) - 1: # test if index is valid

View File

@@ -96,7 +96,7 @@ class LinkedQueue:
>>> queue = LinkedQueue()
>>> queue.get()
Traceback (most recent call last):
...
...
IndexError: dequeue from empty queue
>>> for i in range(1, 6):
... queue.put(i)
@@ -116,7 +116,7 @@ class LinkedQueue:
>>> queue = LinkedQueue()
>>> queue.get()
Traceback (most recent call last):
...
...
IndexError: dequeue from empty queue
>>> queue = LinkedQueue()
>>> for i in range(1, 6):

View File

@@ -58,7 +58,7 @@ class FixedPriorityQueue:
4
>>> fpq.dequeue()
Traceback (most recent call last):
...
...
data_structures.queue.priority_queue_using_list.UnderFlowError: All queues are empty
>>> print(fpq)
Priority 0: []

View File

@@ -21,7 +21,7 @@ def infix_to_postfix(expression_str: str) -> str:
"""
>>> infix_to_postfix("(1*(2+3)+4))")
Traceback (most recent call last):
...
...
ValueError: Mismatched parentheses
>>> infix_to_postfix("")
''

View File

@@ -109,7 +109,7 @@ class LinkedStack(Generic[T]):
>>> stack = LinkedStack()
>>> stack.pop()
Traceback (most recent call last):
...
...
IndexError: pop from empty stack
>>> stack.push("c")
>>> stack.push("b")