Skip to content

Commit 1400c12

Browse files
committed
refactor: Remove useless print and pass statements
1 parent 8ce811b commit 1400c12

28 files changed

+95
-108
lines changed

backtracking/hamiltonian_cycle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def util_hamilton_cycle(graph: list[list[int]], path: list[int], curr_ind: int)
7171
>>> curr_ind = 1
7272
>>> util_hamilton_cycle(graph, path, curr_ind)
7373
True
74-
>>> print(path)
74+
>>> path
7575
[0, 1, 2, 4, 3, 0]
7676
7777
Case 2: Use exact graph as in previous case, but in the properties taken from
@@ -85,7 +85,7 @@ def util_hamilton_cycle(graph: list[list[int]], path: list[int], curr_ind: int)
8585
>>> curr_ind = 3
8686
>>> util_hamilton_cycle(graph, path, curr_ind)
8787
True
88-
>>> print(path)
88+
>>> path
8989
[0, 1, 2, 4, 3, 0]
9090
"""
9191

computer_vision/flip_augmentation.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def main() -> None:
2222
Get images list and annotations list from input dir.
2323
Update new images and annotations.
2424
Save images and annotations in output dir.
25-
>>> pass # A doctest is not possible for this function.
2625
"""
2726
img_paths, annos = get_dataset(LABEL_DIR, IMAGE_DIR)
2827
print("Processing...")
@@ -48,7 +47,6 @@ def get_dataset(label_dir: str, img_dir: str) -> tuple[list, list]:
4847
- label_dir <type: str>: Path to label include annotation of images
4948
- img_dir <type: str>: Path to folder contain images
5049
Return <type: list>: List of images path and labels
51-
>>> pass # A doctest is not possible for this function.
5250
"""
5351
img_paths = []
5452
labels = []
@@ -88,7 +86,6 @@ def update_image_and_anno(
8886
- new_imgs_list <type: narray>: image after resize
8987
- new_annos_lists <type: list>: list of new annotation after scale
9088
- path_list <type: list>: list the name of image file
91-
>>> pass # A doctest is not possible for this function.
9289
"""
9390
new_annos_lists = []
9491
path_list = []

computer_vision/mosaic_augmentation.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def main() -> None:
2323
Get images list and annotations list from input dir.
2424
Update new images and annotations.
2525
Save images and annotations in output dir.
26-
>>> pass # A doctest is not possible for this function.
2726
"""
2827
img_paths, annos = get_dataset(LABEL_DIR, IMG_DIR)
2928
for index in range(NUMBER_IMAGES):
@@ -60,7 +59,6 @@ def get_dataset(label_dir: str, img_dir: str) -> tuple[list, list]:
6059
- label_dir <type: str>: Path to label include annotation of images
6160
- img_dir <type: str>: Path to folder contain images
6261
Return <type: list>: List of images path and labels
63-
>>> pass # A doctest is not possible for this function.
6462
"""
6563
img_paths = []
6664
labels = []
@@ -105,7 +103,6 @@ def update_image_and_anno(
105103
- output_img <type: narray>: image after resize
106104
- new_anno <type: list>: list of new annotation after scale
107105
- path[0] <type: string>: get the name of image file
108-
>>> pass # A doctest is not possible for this function.
109106
"""
110107
output_img = np.zeros([output_size[0], output_size[1], 3], dtype=np.uint8)
111108
scale_x = scale_range[0] + random.random() * (scale_range[1] - scale_range[0])

data_structures/binary_tree/avl_tree.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,28 +248,28 @@ class AVLtree:
248248
>>> t = AVLtree()
249249
>>> t.insert(4)
250250
insert:4
251-
>>> print(str(t).replace(" \\n","\\n"))
251+
>>> str(t).replace(" \\n","\\n")
252252
4
253253
*************************************
254254
>>> t.insert(2)
255255
insert:2
256-
>>> print(str(t).replace(" \\n","\\n").replace(" \\n","\\n"))
256+
>>> str(t).replace(" \\n","\\n").replace(" \\n","\\n")
257257
4
258258
2 *
259259
*************************************
260260
>>> t.insert(3)
261261
insert:3
262262
right rotation node: 2
263263
left rotation node: 4
264-
>>> print(str(t).replace(" \\n","\\n").replace(" \\n","\\n"))
264+
>>> str(t).replace(" \\n","\\n").replace(" \\n","\\n")
265265
3
266266
2 4
267267
*************************************
268268
>>> t.get_height()
269269
2
270270
>>> t.del_node(3)
271271
delete:3
272-
>>> print(str(t).replace(" \\n","\\n").replace(" \\n","\\n"))
272+
>>> str(t).replace(" \\n","\\n").replace(" \\n","\\n")
273273
4
274274
2 *
275275
*************************************

data_structures/binary_tree/binary_search_tree.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ def binary_search_tree() -> None:
190190
191191
>>> t = BinarySearchTree()
192192
>>> t.insert(8, 3, 6, 1, 10, 14, 13, 4, 7)
193-
>>> print(" ".join(repr(i.value) for i in t.traversal_tree()))
193+
>>> " ".join(repr(i.value) for i in t.traversal_tree())
194194
8 3 1 6 4 7 10 14 13
195-
>>> print(" ".join(repr(i.value) for i in t.traversal_tree(postorder)))
195+
>>> " ".join(repr(i.value) for i in t.traversal_tree(postorder))
196196
1 4 7 6 3 13 14 10 8
197197
>>> BinarySearchTree().search(6)
198198
Traceback (most recent call last):

data_structures/heap/binomial_heap.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class BinomialHeap:
7171
... first_heap.insert(number)
7272
7373
Size test
74-
>>> print(first_heap.size)
74+
>>> first_heap.size
7575
30
7676
7777
Deleting - delete() test
@@ -97,11 +97,11 @@ class BinomialHeap:
9797
# # # #
9898
9999
preOrder() test
100-
>>> print(second_heap.preOrder())
100+
>>> second_heap.preOrder()
101101
[(17, 0), ('#', 1), (31, 1), (20, 2), ('#', 3), ('#', 3), (34, 2), ('#', 3), ('#', 3)]
102102
103103
printing Heap - __str__() test
104-
>>> print(second_heap)
104+
>>> second_heap
105105
17
106106
-#
107107
-31

data_structures/heap/heap.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ class Heap:
99
>>> unsorted = [103, 9, 1, 7, 11, 15, 25, 201, 209, 107, 5]
1010
>>> h = Heap()
1111
>>> h.build_max_heap(unsorted)
12-
>>> print(h)
12+
>>> h
1313
[209, 201, 25, 103, 107, 15, 1, 9, 7, 11, 5]
1414
>>>
1515
>>> h.extract_max()
1616
209
17-
>>> print(h)
17+
>>> h
1818
[201, 107, 25, 103, 11, 15, 1, 9, 7, 5]
1919
>>>
2020
>>> h.insert(100)
21-
>>> print(h)
21+
>>> h
2222
[201, 107, 25, 103, 100, 15, 1, 9, 7, 5, 11]
2323
>>>
2424
>>> h.heap_sort()
25-
>>> print(h)
25+
>>> h
2626
[1, 5, 7, 9, 11, 15, 25, 100, 103, 107, 201]
2727
"""
2828

data_structures/heap/min_heap.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ class MinHeap:
2121
>>> a = Node("A", 3)
2222
>>> x = Node("X", 1)
2323
>>> e = Node("E", 4)
24-
>>> print(b)
24+
>>> b
2525
Node(B, 6)
2626
>>> myMinHeap = MinHeap([r, b, a, x, e])
2727
>>> myMinHeap.decrease_key(b, -17)
28-
>>> print(b)
28+
>>> b
2929
Node(B, -17)
30-
>>> print(myMinHeap["B"])
30+
>>> myMinHeap["B"]
3131
-17
3232
"""
3333

data_structures/linked_list/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __str__(self) -> str:
4646
>>> linked_list.add(23)
4747
>>> linked_list.add(14)
4848
>>> linked_list.add(9)
49-
>>> print(linked_list)
49+
>>> linked_list
5050
9 --> 14 --> 23
5151
"""
5252
if not self.is_empty:

data_structures/linked_list/skip_list.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ def __str__(self) -> str:
5959
:return: Visual representation of SkipList
6060
6161
>>> skip_list = SkipList()
62-
>>> print(skip_list)
62+
>>> skip_list
6363
SkipList(level=0)
6464
>>> skip_list.insert("Key1", "Value")
65-
>>> print(skip_list) # doctest: +ELLIPSIS
65+
>>> skip_list # doctest: +ELLIPSIS
6666
SkipList(level=...
6767
[root]--...
6868
[Key1]--Key1...
6969
None *...
7070
>>> skip_list.insert("Key2", "OtherValue")
71-
>>> print(skip_list) # doctest: +ELLIPSIS
71+
>>> skip_list # doctest: +ELLIPSIS
7272
SkipList(level=...
7373
[root]--...
7474
[Key1]--Key1...

data_structures/queue/priority_queue_using_list.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class FixedPriorityQueue:
3030
>>> fpq.enqueue(2, 4)
3131
>>> fpq.enqueue(1, 64)
3232
>>> fpq.enqueue(0, 128)
33-
>>> print(fpq)
33+
>>> fpq
3434
Priority 0: [10, 100, 128]
3535
Priority 1: [70, 7, 64]
3636
Priority 2: [1, 5, 4]
@@ -44,7 +44,7 @@ class FixedPriorityQueue:
4444
70
4545
>>> fpq.dequeue()
4646
7
47-
>>> print(fpq)
47+
>>> fpq
4848
Priority 0: []
4949
Priority 1: [64]
5050
Priority 2: [1, 5, 4]
@@ -60,7 +60,7 @@ class FixedPriorityQueue:
6060
Traceback (most recent call last):
6161
...
6262
data_structures.queue.priority_queue_using_list.UnderFlowError: All queues are empty
63-
>>> print(fpq)
63+
>>> fpq
6464
Priority 0: []
6565
Priority 1: []
6666
Priority 2: []
@@ -116,7 +116,7 @@ class ElementPriorityQueue:
116116
>>> epq.enqueue(4)
117117
>>> epq.enqueue(64)
118118
>>> epq.enqueue(128)
119-
>>> print(epq)
119+
>>> epq
120120
[10, 70, 4, 1, 5, 7, 4, 64, 128]
121121
>>> epq.dequeue()
122122
1
@@ -130,7 +130,7 @@ class ElementPriorityQueue:
130130
7
131131
>>> epq.dequeue()
132132
10
133-
>>> print(epq)
133+
>>> epq
134134
[70, 64, 128]
135135
>>> epq.dequeue()
136136
64
@@ -142,7 +142,7 @@ class ElementPriorityQueue:
142142
Traceback (most recent call last):
143143
...
144144
data_structures.queue.priority_queue_using_list.UnderFlowError: The queue is empty
145-
>>> print(epq)
145+
>>> epq
146146
[]
147147
"""
148148

graphs/gale_shapley_bigraph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def stable_matching(
1717
1818
>>> donor_pref = [[0, 1, 3, 2], [0, 2, 3, 1], [1, 0, 2, 3], [0, 3, 1, 2]]
1919
>>> recipient_pref = [[3, 1, 2, 0], [3, 1, 0, 2], [0, 3, 1, 2], [1, 0, 3, 2]]
20-
>>> print(stable_matching(donor_pref, recipient_pref))
20+
>>> stable_matching(donor_pref, recipient_pref)
2121
[1, 2, 3, 0]
2222
"""
2323
assert len(donor_pref) == len(recipient_pref)

graphs/graph_list.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ class GraphAdjacencyList(Generic[T]):
2626
{0: [1], 1: [2, 4, 5], 2: [], 4: [], 5: []}
2727
>>> d_graph.add_edge(2, 0).add_edge(2, 6).add_edge(2, 7)
2828
{0: [1], 1: [2, 4, 5], 2: [0, 6, 7], 4: [], 5: [], 6: [], 7: []}
29-
>>> print(d_graph)
29+
>>> d_graph
3030
{0: [1], 1: [2, 4, 5], 2: [0, 6, 7], 4: [], 5: [], 6: [], 7: []}
31-
>>> print(repr(d_graph))
31+
>>> repr(d_graph)
3232
{0: [1], 1: [2, 4, 5], 2: [0, 6, 7], 4: [], 5: [], 6: [], 7: []}
3333
3434
Undirected graph example:
@@ -47,15 +47,15 @@ class GraphAdjacencyList(Generic[T]):
4747
5: [1, 4],
4848
6: [2],
4949
7: [2]}
50-
>>> print(u_graph)
50+
>>> u_graph
5151
{0: [1, 2],
5252
1: [0, 2, 4, 5],
5353
2: [1, 0, 6, 7],
5454
4: [1, 5],
5555
5: [1, 4],
5656
6: [2],
5757
7: [2]}
58-
>>> print(repr(u_graph))
58+
>>> repr(u_graph)
5959
{0: [1, 2],
6060
1: [0, 2, 4, 5],
6161
2: [1, 0, 6, 7],
@@ -68,7 +68,7 @@ class GraphAdjacencyList(Generic[T]):
6868
{'a': ['b'], 'b': ['a']}
6969
>>> char_graph.add_edge('b', 'c').add_edge('b', 'e').add_edge('b', 'f')
7070
{'a': ['b'], 'b': ['a', 'c', 'e', 'f'], 'c': ['b'], 'e': ['b'], 'f': ['b']}
71-
>>> print(char_graph)
71+
>>> char_graph
7272
{'a': ['b'], 'b': ['a', 'c', 'e', 'f'], 'c': ['b'], 'e': ['b'], 'f': ['b']}
7373
"""
7474

graphs/minimum_spanning_tree_boruvka.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def boruvka_mst(graph):
154154
>>> g = Graph.build([0, 1, 2, 3], [[0, 1, 1], [0, 2, 1],[2, 3, 1]])
155155
>>> g.distinct_weight()
156156
>>> bg = Graph.boruvka_mst(g)
157-
>>> print(bg)
157+
>>> bg
158158
1 -> 0 == 1
159159
2 -> 0 == 2
160160
0 -> 1 == 1

graphs/minimum_spanning_tree_prims2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ class MinPriorityQueue(Generic[T]):
6969
>>> queue.push(3, 4000)
7070
>>> queue.push(4, 3000)
7171
72-
>>> print(queue.extract_min())
72+
>>> queue.extract_min()
7373
2
7474
7575
>>> queue.update_key(4, 50)
7676
77-
>>> print(queue.extract_min())
77+
>>> queue.extract_min()
7878
4
79-
>>> print(queue.extract_min())
79+
>>> queue.extract_min()
8080
1
81-
>>> print(queue.extract_min())
81+
>>> queue.extract_min()
8282
3
8383
"""
8484

graphs/random_graph_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def complete_graph(vertices_number: int) -> dict:
5353
@input: vertices_number (number of vertices),
5454
directed (False if the graph is undirected, True otherwise)
5555
@example:
56-
>>> print(complete_graph(3))
56+
>>> complete_graph(3)
5757
{0: [1, 2], 1: [0, 2], 2: [0, 1]}
5858
"""
5959
return {

linear_algebra/src/polynom_for_points.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@ def points_to_polynomial(coordinates: list[list[int]]) -> str:
33
coordinates is a two dimensional matrix: [[x, y], [x, y], ...]
44
number of points you want to use
55
6-
>>> print(points_to_polynomial([]))
6+
>>> points_to_polynomial([])
77
The program cannot work out a fitting polynomial.
8-
>>> print(points_to_polynomial([[]]))
8+
>>> points_to_polynomial([[]])
99
The program cannot work out a fitting polynomial.
10-
>>> print(points_to_polynomial([[1, 0], [2, 0], [3, 0]]))
10+
>>> points_to_polynomial([[1, 0], [2, 0], [3, 0]])
1111
f(x)=x^2*0.0+x^1*-0.0+x^0*0.0
12-
>>> print(points_to_polynomial([[1, 1], [2, 1], [3, 1]]))
12+
>>> points_to_polynomial([[1, 1], [2, 1], [3, 1]])
1313
f(x)=x^2*0.0+x^1*-0.0+x^0*1.0
14-
>>> print(points_to_polynomial([[1, 3], [2, 3], [3, 3]]))
14+
>>> points_to_polynomial([[1, 3], [2, 3], [3, 3]])
1515
f(x)=x^2*0.0+x^1*-0.0+x^0*3.0
16-
>>> print(points_to_polynomial([[1, 1], [2, 2], [3, 3]]))
16+
>>> points_to_polynomial([[1, 1], [2, 2], [3, 3]])
1717
f(x)=x^2*0.0+x^1*1.0+x^0*0.0
18-
>>> print(points_to_polynomial([[1, 1], [2, 4], [3, 9]]))
18+
>>> points_to_polynomial([[1, 1], [2, 4], [3, 9]])
1919
f(x)=x^2*1.0+x^1*-0.0+x^0*0.0
20-
>>> print(points_to_polynomial([[1, 3], [2, 6], [3, 11]]))
20+
>>> points_to_polynomial([[1, 3], [2, 6], [3, 11]])
2121
f(x)=x^2*1.0+x^1*-0.0+x^0*2.0
22-
>>> print(points_to_polynomial([[1, -3], [2, -6], [3, -11]]))
22+
>>> points_to_polynomial([[1, -3], [2, -6], [3, -11]])
2323
f(x)=x^2*-1.0+x^1*-0.0+x^0*-2.0
24-
>>> print(points_to_polynomial([[1, 5], [2, 2], [3, 9]]))
24+
>>> points_to_polynomial([[1, 5], [2, 2], [3, 9]])
2525
f(x)=x^2*5.0+x^1*-18.0+x^0*18.0
2626
"""
2727
try:

machine_learning/local_weighted_learning/local_weighted_learning.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ def local_weight_regression(
7171
def load_data(dataset_name: str, cola_name: str, colb_name: str) -> np.mat:
7272
"""
7373
Function used for loading data from the seaborn splitting into x and y points
74-
>>> pass # this function has no doctest
7574
"""
7675
import seaborn as sns
7776

@@ -112,7 +111,6 @@ def plot_preds(
112111
) -> plt.plot:
113112
"""
114113
This function used to plot predictions and display the graph
115-
>>> pass #this function has no doctest
116114
"""
117115
xsort = training_data_x.copy()
118116
xsort.sort(axis=0)

0 commit comments

Comments
 (0)