This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Importing the main pipeline function | |
| from pipeline.pipeline import pipeline | |
| # Directory traversal | |
| import os | |
| # Data frame objects | |
| import pandas as pd | |
| # Defining the test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Importing the function to test | |
| from pipeline.modules.read_data import read_json | |
| # Dir traversal | |
| import os | |
| def test_data_reading(): | |
| """ | |
| Tests the data reading functionality of the pipeline | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Base class | |
| from algorithms.BaseClass import BaseClass | |
| class BubbleSort(BaseClass): | |
| def __init__(self, arr: list): | |
| """ | |
| Object constructor | |
| Arguments |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Maximum number of array length | |
| _max_length = 50 | |
| # Defining the amount of expiremnts in each test | |
| _n_experiments = 200 | |
| # Iteration results | |
| _iter_results = [] | |
| for i in range(_max_length + 1): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BaseClass: | |
| def __init__( | |
| self, | |
| arr: list = [float] | |
| ): | |
| """ | |
| The base class for all the algorithms to inherit from | |
| """ | |
| # Ensuring the correct type | |
| if type(arr) != list: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Importing the base class | |
| from algorithms.BaseClass import BaseClass | |
| class SelectionSort(BaseClass): | |
| def __init__( | |
| self, | |
| arr:list | |
| ): | |
| # Inheriting the base class |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Importing the base class | |
| from algorithms.BaseClass import BaseClass | |
| class InsertionSort(BaseClass): | |
| def __init__( | |
| self, | |
| arr: list | |
| ): | |
| # Inheriting the base class constructor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def factorial(n: int) -> float: | |
| """ | |
| Given a positive integer, calculate its factorial | |
| """ | |
| if not isinstance(n, int): | |
| raise TypeError('n must be an integer') | |
| if n < 0: | |
| raise ValueError("n must be positive") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Base class | |
| from algorithms.BaseClass import BaseClass | |
| class MergeSort(BaseClass): | |
| def __init__(self, arr): | |
| # Inheriting from base class | |
| super().__init__(arr) | |
| # Initiating the recursive splitting of the arrays |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Base class | |
| from algorithms.BaseClass import BaseClass | |
| class QuickSort(BaseClass): | |
| def __init__(self, arr): | |
| # Inheriting from base class | |
| super().__init__(arr) | |
| # Indication whether the current element is partitioned or not |