A New Project API References
data_processing.sort module
- data_processing.sort.insertion_sort.sortInsertionAsc(alist: list) None
- Apply insertion sort in ascending order on a list - Parameters:
- alist (list) – The list to be sorted 
 
- data_processing.sort.insertion_sort.sortInsertionDesc(alist: list) None
- Apply insertion sort in decending order on a list - Parameters:
- alist (list) – The list to be sorted 
 
- data_processing.sort.pigeonhole_sort.pigeonHoleSortAsc(alist: list, maxvalue: int = 160000)
- Apply pigeon-hole sort in ascending order on a list - Parameters:
- alist (list) – The list to be sorted 
- maxvalue (int, optional) – The maximum value in the list, defaults to 160000 
 
 
- data_processing.sort.selection_sort.sortSelectionAsc(alist: list) None
- Apply selection sort in ascending order on a list - Parameters:
- alist (list) – The list to be sorted 
 
- data_processing.sort.selection_sort.sortSelectionDesc(alist: list) None
- Apply selection sort in decending order on a list - Parameters:
- alist (list) – The list to be sorted 
 
data_processing.structures module
- class data_processing.structures.binary_tree_adt.BSTree
- Bases: - object- Models a binary search tree (BST) - countNodes() int
- Returns the number of nodes in a binary search tree - Returns:
- The number of nodes 
- Return type:
- int 
 
 - insert(key, data=None)
- Insert a data as a node in this BST - Parameters:
- key (any immutable type) – The key for the binary search tree 
- data (any, optional) – The payload, defaults to None 
 
 
 - printInOrder()
- Print the data in a binary search tree in in-order traveral 
 - printInOrderReverse()
- Print the data in a binary search tree in reverse in-order traveral 
 - printPostOrder()
- Print the data in a binary search tree in post-order traveral 
 - printPreOrder()
- Print the data in a binary search tree in pre-order traveral 
 - searchKey(key)
- Search for the node that contains the key in this BST - Parameters:
- key (any immutable type) – The key for the binary search tree 
- Returns:
- The node or None if not found 
- Return type:
- any 
 
 - treeHeight() int
- Returns the height of a binary search tree - Returns:
- The tree height 
- Return type:
- int 
 
 
- class data_processing.structures.binary_tree_adt.Node(key, data=None)
- Bases: - object- Models a node in a binary search tree - countNodes() int
- Returns the number of nodes in a binary search tree - Returns:
- The number of nodes 
- Return type:
- int 
 
 - insert(key, data=None)
- Insert data as a nodein the binary search tree - Parameters:
- key (any immutable type) – The key for the binary search tree 
- data (any, optional) – The payload, defaults to None 
 
 
 - printInOrder()
- Print the data in a binary search tree in in-order traveral 
 - printInOrderReverse()
- Print the data in a binary search tree in reverse in-order traveral 
 - printPostOrder()
- Print the data in a binary search tree in post-order traveral 
 - printPreOrder()
- Print the data in a binary search tree in pre-order traveral 
 - searchKey(key)
- Search for data using the query key - Parameters:
- key (any immutable type) – The key for the binary search tree 
- Returns:
- The data or None if the key is not found 
- Return type:
- any 
 
 - treeHeight() int
- Returns the height of a binary search tree - Returns:
- The tree height 
- Return type:
- int 
 
 
- class data_processing.structures.linked_list_adt.LinkedList
- Bases: - object- Models a linkdd list - delete(index: int)
- Delete the node at a given index - Parameters:
- index (int) – The index of the node to be deleted 
- Raises:
- IndexError – The index is out of range 
 
 - deleteNodeOfData(targetdata)
- Delete the node containing the target data - Parameters:
- targetdata (any) – The target data of which the node is to be deleted 
 
 - insert(data)
- Insert new data at the front of linked list - Parameters:
- data (any) – The data to be inserted 
 
 - insertEnd(data)
- Insert new data at the end of linked list - Parameters:
- data (any) – The data to be inserted 
 
 - print()
- Printing all nodes by traversal 
 
- class data_processing.structures.linked_list_adt.Node(data=None)
- Bases: - object- Models the node of a linked list 
- class data_processing.structures.queue.Queue
- Bases: - object- Models a FIFO queue - deQueue()
- Remove the value at the front of the queue - Raises:
- IndexError – The queue is empty 
- Returns:
- The data removed at the front 
- Return type:
- any 
 
 - enQueue(value)
- Add a value at the end of the queue - Parameters:
- value (any) – The value to be added 
 
 - isEmpty() bool
- Returns True if the queue is empty - Returns:
- True if the queue is empty 
- Return type:
- bool 
 
 - isFull() bool
- Returns True if the queue is full - Returns:
- True if the queue is full 
- Return type:
- bool 
 
 - print(sep=',')
- Print the content of the queue - Parameters:
- sep (str, optional) – The separating character between the values in the queue, defaults to ‘,’ 
 
 
- class data_processing.structures.stack.Stack
- Bases: - object- Models a FILO stack - isEmpty() bool
- Returns True if the queue is empty - Returns:
- True if the queue is empty 
- Return type:
- bool 
 
 - isFull() bool
- Returns True if the queue is full - Returns:
- True if the queue is full 
- Return type:
- bool 
 
 - pop()
- Remove the value on the top of the stack - Raises:
- IndexError – The stack is empty 
- Returns:
- The value at the top of the stack 
- Return type:
- any 
 
 - print(sep=',')
- Print the content of the queue - Parameters:
- sep (str, optional) – The separating character between the values in the queue, defaults to ‘,’ 
 
 - push(value)
- Push the value on top of the stack - Parameters:
- value (any) – The value to be pushed to the stack 
 
 
tools module
- tools.opencv_tools.compare_masks(mask1, mask2) float
- Find the similarity of two marks - Parameters:
- mask1 (np.array) – The first mark image for comparison 
- mask2 (np.array) – The second mark image for comparison 
 
- Returns:
- The similarity score 
- Return type:
- float 
 
- tools.opencv_tools.copy_and_pad(mask, row: int, col: int) numpy.array
- Create a new image of shape (row, col) and copy the mask referenced at the center - Parameters:
- mask (np.array) – The source mask image 
- row (int) – The number of rows in the new image 
- col (int) – The number of columns in the new image 
 
- Returns:
- The new image 
- Return type:
- np.array 
 
- tools.opencv_tools.extract_masked_points(image_mask, mask_value=255) set
- Extracts masked location as a set - Args:
- image_mask (nparray or cvimage): 2d nparray of integers mask_value (bool): the value representing the mask 
- Returns:
- list: a list of points (tuples of (row, col)) of the mask 
 
- tools.opencv_tools.extract_region(seed, points)
- Gather a connected region from the points of mask, starting from the seed - Args:
- image_mask (nparray or cvimage): 2d nparray of integers mask_value (bool): the value representing the mask 
- Returns:
- list: a list of points (tuples of (row, col)) of the mask 
 
- tools.opencv_tools.generate_neighbours(point)
- Private: