Skip to content

Remove useless code in doctests #7732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backtracking/hamiltonian_cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def util_hamilton_cycle(graph: list[list[int]], path: list[int], curr_ind: int)
>>> curr_ind = 1
>>> util_hamilton_cycle(graph, path, curr_ind)
True
>>> print(path)
>>> path
[0, 1, 2, 4, 3, 0]

Case 2: Use exact graph as in previous case, but in the properties taken from
Expand All @@ -85,7 +85,7 @@ def util_hamilton_cycle(graph: list[list[int]], path: list[int], curr_ind: int)
>>> curr_ind = 3
>>> util_hamilton_cycle(graph, path, curr_ind)
True
>>> print(path)
>>> path
[0, 1, 2, 4, 3, 0]
"""

Expand Down
3 changes: 0 additions & 3 deletions computer_vision/flip_augmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def main() -> None:
Get images list and annotations list from input dir.
Update new images and annotations.
Save images and annotations in output dir.
>>> pass # A doctest is not possible for this function.
"""
img_paths, annos = get_dataset(LABEL_DIR, IMAGE_DIR)
print("Processing...")
Expand All @@ -48,7 +47,6 @@ def get_dataset(label_dir: str, img_dir: str) -> tuple[list, list]:
- label_dir <type: str>: Path to label include annotation of images
- img_dir <type: str>: Path to folder contain images
Return <type: list>: List of images path and labels
>>> pass # A doctest is not possible for this function.
"""
img_paths = []
labels = []
Expand Down Expand Up @@ -88,7 +86,6 @@ def update_image_and_anno(
- new_imgs_list <type: narray>: image after resize
- new_annos_lists <type: list>: list of new annotation after scale
- path_list <type: list>: list the name of image file
>>> pass # A doctest is not possible for this function.
"""
new_annos_lists = []
path_list = []
Expand Down
3 changes: 0 additions & 3 deletions computer_vision/mosaic_augmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def main() -> None:
Get images list and annotations list from input dir.
Update new images and annotations.
Save images and annotations in output dir.
>>> pass # A doctest is not possible for this function.
"""
img_paths, annos = get_dataset(LABEL_DIR, IMG_DIR)
for index in range(NUMBER_IMAGES):
Expand Down Expand Up @@ -60,7 +59,6 @@ def get_dataset(label_dir: str, img_dir: str) -> tuple[list, list]:
- label_dir <type: str>: Path to label include annotation of images
- img_dir <type: str>: Path to folder contain images
Return <type: list>: List of images path and labels
>>> pass # A doctest is not possible for this function.
"""
img_paths = []
labels = []
Expand Down Expand Up @@ -105,7 +103,6 @@ def update_image_and_anno(
- output_img <type: narray>: image after resize
- new_anno <type: list>: list of new annotation after scale
- path[0] <type: string>: get the name of image file
>>> pass # A doctest is not possible for this function.
"""
output_img = np.zeros([output_size[0], output_size[1], 3], dtype=np.uint8)
scale_x = scale_range[0] + random.random() * (scale_range[1] - scale_range[0])
Expand Down
8 changes: 4 additions & 4 deletions data_structures/binary_tree/avl_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,28 +248,28 @@ class AVLtree:
>>> t = AVLtree()
>>> t.insert(4)
insert:4
>>> print(str(t).replace(" \\n","\\n"))
>>> str(t).replace(" \\n","\\n")
4
*************************************
>>> t.insert(2)
insert:2
>>> print(str(t).replace(" \\n","\\n").replace(" \\n","\\n"))
>>> str(t).replace(" \\n","\\n").replace(" \\n","\\n")
4
2 *
*************************************
>>> t.insert(3)
insert:3
right rotation node: 2
left rotation node: 4
>>> print(str(t).replace(" \\n","\\n").replace(" \\n","\\n"))
>>> str(t).replace(" \\n","\\n").replace(" \\n","\\n")
3
2 4
*************************************
>>> t.get_height()
2
>>> t.del_node(3)
delete:3
>>> print(str(t).replace(" \\n","\\n").replace(" \\n","\\n"))
>>> str(t).replace(" \\n","\\n").replace(" \\n","\\n")
4
2 *
*************************************
Expand Down
4 changes: 2 additions & 2 deletions data_structures/binary_tree/binary_search_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ def binary_search_tree() -> None:

>>> t = BinarySearchTree()
>>> t.insert(8, 3, 6, 1, 10, 14, 13, 4, 7)
>>> print(" ".join(repr(i.value) for i in t.traversal_tree()))
>>> " ".join(repr(i.value) for i in t.traversal_tree())
8 3 1 6 4 7 10 14 13
>>> print(" ".join(repr(i.value) for i in t.traversal_tree(postorder)))
>>> " ".join(repr(i.value) for i in t.traversal_tree(postorder))
1 4 7 6 3 13 14 10 8
>>> BinarySearchTree().search(6)
Traceback (most recent call last):
Expand Down
6 changes: 3 additions & 3 deletions data_structures/heap/binomial_heap.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class BinomialHeap:
... first_heap.insert(number)

Size test
>>> print(first_heap.size)
>>> first_heap.size
30

Deleting - delete() test
Expand All @@ -97,11 +97,11 @@ class BinomialHeap:
# # # #

preOrder() test
>>> print(second_heap.preOrder())
>>> second_heap.preOrder()
[(17, 0), ('#', 1), (31, 1), (20, 2), ('#', 3), ('#', 3), (34, 2), ('#', 3), ('#', 3)]

printing Heap - __str__() test
>>> print(second_heap)
>>> second_heap
17
-#
-31
Expand Down
8 changes: 4 additions & 4 deletions data_structures/heap/heap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,20 @@ class Heap:
>>> unsorted = [103, 9, 1, 7, 11, 15, 25, 201, 209, 107, 5]
>>> h = Heap()
>>> h.build_max_heap(unsorted)
>>> print(h)
>>> h
[209, 201, 25, 103, 107, 15, 1, 9, 7, 11, 5]
>>>
>>> h.extract_max()
209
>>> print(h)
>>> h
[201, 107, 25, 103, 11, 15, 1, 9, 7, 5]
>>>
>>> h.insert(100)
>>> print(h)
>>> h
[201, 107, 25, 103, 100, 15, 1, 9, 7, 5, 11]
>>>
>>> h.heap_sort()
>>> print(h)
>>> h
[1, 5, 7, 9, 11, 15, 25, 100, 103, 107, 201]
"""

Expand Down
6 changes: 3 additions & 3 deletions data_structures/heap/min_heap.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class MinHeap:
>>> a = Node("A", 3)
>>> x = Node("X", 1)
>>> e = Node("E", 4)
>>> print(b)
>>> b
Node(B, 6)
>>> myMinHeap = MinHeap([r, b, a, x, e])
>>> myMinHeap.decrease_key(b, -17)
>>> print(b)
>>> b
Node(B, -17)
>>> print(myMinHeap["B"])
>>> myMinHeap["B"]
-17
"""

Expand Down
2 changes: 1 addition & 1 deletion data_structures/linked_list/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __str__(self) -> str:
>>> linked_list.add(23)
>>> linked_list.add(14)
>>> linked_list.add(9)
>>> print(linked_list)
>>> linked_list
9 --> 14 --> 23
"""
if not self.is_empty:
Expand Down
6 changes: 3 additions & 3 deletions data_structures/linked_list/skip_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@ def __str__(self) -> str:
:return: Visual representation of SkipList

>>> skip_list = SkipList()
>>> print(skip_list)
>>> skip_list
SkipList(level=0)
>>> skip_list.insert("Key1", "Value")
>>> print(skip_list) # doctest: +ELLIPSIS
>>> skip_list # doctest: +ELLIPSIS
SkipList(level=...
[root]--...
[Key1]--Key1...
None *...
>>> skip_list.insert("Key2", "OtherValue")
>>> print(skip_list) # doctest: +ELLIPSIS
>>> skip_list # doctest: +ELLIPSIS
SkipList(level=...
[root]--...
[Key1]--Key1...
Expand Down
12 changes: 6 additions & 6 deletions data_structures/queue/priority_queue_using_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class FixedPriorityQueue:
>>> fpq.enqueue(2, 4)
>>> fpq.enqueue(1, 64)
>>> fpq.enqueue(0, 128)
>>> print(fpq)
>>> fpq
Priority 0: [10, 100, 128]
Priority 1: [70, 7, 64]
Priority 2: [1, 5, 4]
Expand All @@ -44,7 +44,7 @@ class FixedPriorityQueue:
70
>>> fpq.dequeue()
7
>>> print(fpq)
>>> fpq
Priority 0: []
Priority 1: [64]
Priority 2: [1, 5, 4]
Expand All @@ -60,7 +60,7 @@ class FixedPriorityQueue:
Traceback (most recent call last):
...
data_structures.queue.priority_queue_using_list.UnderFlowError: All queues are empty
>>> print(fpq)
>>> fpq
Priority 0: []
Priority 1: []
Priority 2: []
Expand Down Expand Up @@ -116,7 +116,7 @@ class ElementPriorityQueue:
>>> epq.enqueue(4)
>>> epq.enqueue(64)
>>> epq.enqueue(128)
>>> print(epq)
>>> epq
[10, 70, 4, 1, 5, 7, 4, 64, 128]
>>> epq.dequeue()
1
Expand All @@ -130,7 +130,7 @@ class ElementPriorityQueue:
7
>>> epq.dequeue()
10
>>> print(epq)
>>> epq
[70, 64, 128]
>>> epq.dequeue()
64
Expand All @@ -142,7 +142,7 @@ class ElementPriorityQueue:
Traceback (most recent call last):
...
data_structures.queue.priority_queue_using_list.UnderFlowError: The queue is empty
>>> print(epq)
>>> epq
[]
"""

Expand Down
2 changes: 1 addition & 1 deletion graphs/gale_shapley_bigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def stable_matching(

>>> donor_pref = [[0, 1, 3, 2], [0, 2, 3, 1], [1, 0, 2, 3], [0, 3, 1, 2]]
>>> recipient_pref = [[3, 1, 2, 0], [3, 1, 0, 2], [0, 3, 1, 2], [1, 0, 3, 2]]
>>> print(stable_matching(donor_pref, recipient_pref))
>>> stable_matching(donor_pref, recipient_pref)
[1, 2, 3, 0]
"""
assert len(donor_pref) == len(recipient_pref)
Expand Down
10 changes: 5 additions & 5 deletions graphs/graph_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class GraphAdjacencyList(Generic[T]):
{0: [1], 1: [2, 4, 5], 2: [], 4: [], 5: []}
>>> d_graph.add_edge(2, 0).add_edge(2, 6).add_edge(2, 7)
{0: [1], 1: [2, 4, 5], 2: [0, 6, 7], 4: [], 5: [], 6: [], 7: []}
>>> print(d_graph)
>>> d_graph
{0: [1], 1: [2, 4, 5], 2: [0, 6, 7], 4: [], 5: [], 6: [], 7: []}
>>> print(repr(d_graph))
>>> repr(d_graph)
{0: [1], 1: [2, 4, 5], 2: [0, 6, 7], 4: [], 5: [], 6: [], 7: []}

Undirected graph example:
Expand All @@ -47,15 +47,15 @@ class GraphAdjacencyList(Generic[T]):
5: [1, 4],
6: [2],
7: [2]}
>>> print(u_graph)
>>> u_graph
{0: [1, 2],
1: [0, 2, 4, 5],
2: [1, 0, 6, 7],
4: [1, 5],
5: [1, 4],
6: [2],
7: [2]}
>>> print(repr(u_graph))
>>> repr(u_graph)
{0: [1, 2],
1: [0, 2, 4, 5],
2: [1, 0, 6, 7],
Expand All @@ -68,7 +68,7 @@ class GraphAdjacencyList(Generic[T]):
{'a': ['b'], 'b': ['a']}
>>> char_graph.add_edge('b', 'c').add_edge('b', 'e').add_edge('b', 'f')
{'a': ['b'], 'b': ['a', 'c', 'e', 'f'], 'c': ['b'], 'e': ['b'], 'f': ['b']}
>>> print(char_graph)
>>> char_graph
{'a': ['b'], 'b': ['a', 'c', 'e', 'f'], 'c': ['b'], 'e': ['b'], 'f': ['b']}
"""

Expand Down
2 changes: 1 addition & 1 deletion graphs/minimum_spanning_tree_boruvka.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def boruvka_mst(graph):
>>> g = Graph.build([0, 1, 2, 3], [[0, 1, 1], [0, 2, 1],[2, 3, 1]])
>>> g.distinct_weight()
>>> bg = Graph.boruvka_mst(g)
>>> print(bg)
>>> bg
1 -> 0 == 1
2 -> 0 == 2
0 -> 1 == 1
Expand Down
8 changes: 4 additions & 4 deletions graphs/minimum_spanning_tree_prims2.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ class MinPriorityQueue(Generic[T]):
>>> queue.push(3, 4000)
>>> queue.push(4, 3000)

>>> print(queue.extract_min())
>>> queue.extract_min()
2

>>> queue.update_key(4, 50)

>>> print(queue.extract_min())
>>> queue.extract_min()
4
>>> print(queue.extract_min())
>>> queue.extract_min()
1
>>> print(queue.extract_min())
>>> queue.extract_min()
3
"""

Expand Down
2 changes: 1 addition & 1 deletion graphs/random_graph_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def complete_graph(vertices_number: int) -> dict:
@input: vertices_number (number of vertices),
directed (False if the graph is undirected, True otherwise)
@example:
>>> print(complete_graph(3))
>>> complete_graph(3)
{0: [1, 2], 1: [0, 2], 2: [0, 1]}
"""
return {
Expand Down
20 changes: 10 additions & 10 deletions linear_algebra/src/polynom_for_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ def points_to_polynomial(coordinates: list[list[int]]) -> str:
coordinates is a two dimensional matrix: [[x, y], [x, y], ...]
number of points you want to use

>>> print(points_to_polynomial([]))
>>> points_to_polynomial([])
The program cannot work out a fitting polynomial.
>>> print(points_to_polynomial([[]]))
>>> points_to_polynomial([[]])
The program cannot work out a fitting polynomial.
>>> print(points_to_polynomial([[1, 0], [2, 0], [3, 0]]))
>>> points_to_polynomial([[1, 0], [2, 0], [3, 0]])
f(x)=x^2*0.0+x^1*-0.0+x^0*0.0
>>> print(points_to_polynomial([[1, 1], [2, 1], [3, 1]]))
>>> points_to_polynomial([[1, 1], [2, 1], [3, 1]])
f(x)=x^2*0.0+x^1*-0.0+x^0*1.0
>>> print(points_to_polynomial([[1, 3], [2, 3], [3, 3]]))
>>> points_to_polynomial([[1, 3], [2, 3], [3, 3]])
f(x)=x^2*0.0+x^1*-0.0+x^0*3.0
>>> print(points_to_polynomial([[1, 1], [2, 2], [3, 3]]))
>>> points_to_polynomial([[1, 1], [2, 2], [3, 3]])
f(x)=x^2*0.0+x^1*1.0+x^0*0.0
>>> print(points_to_polynomial([[1, 1], [2, 4], [3, 9]]))
>>> points_to_polynomial([[1, 1], [2, 4], [3, 9]])
f(x)=x^2*1.0+x^1*-0.0+x^0*0.0
>>> print(points_to_polynomial([[1, 3], [2, 6], [3, 11]]))
>>> points_to_polynomial([[1, 3], [2, 6], [3, 11]])
f(x)=x^2*1.0+x^1*-0.0+x^0*2.0
>>> print(points_to_polynomial([[1, -3], [2, -6], [3, -11]]))
>>> points_to_polynomial([[1, -3], [2, -6], [3, -11]])
f(x)=x^2*-1.0+x^1*-0.0+x^0*-2.0
>>> print(points_to_polynomial([[1, 5], [2, 2], [3, 9]]))
>>> points_to_polynomial([[1, 5], [2, 2], [3, 9]])
f(x)=x^2*5.0+x^1*-18.0+x^0*18.0
"""
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def local_weight_regression(
def load_data(dataset_name: str, cola_name: str, colb_name: str) -> np.mat:
"""
Function used for loading data from the seaborn splitting into x and y points
>>> pass # this function has no doctest
"""
import seaborn as sns

Expand Down Expand Up @@ -112,7 +111,6 @@ def plot_preds(
) -> plt.plot:
"""
This function used to plot predictions and display the graph
>>> pass #this function has no doctest
"""
xsort = training_data_x.copy()
xsort.sort(axis=0)
Expand Down
Loading