A powerful falgopy package
Project description
How to use
# Binary search example
from falgopy.searching.searching_algorithm.searching_algorithm_input import SearchingAlgorithmInput
from falgopy.searching.algorithms.binary_search.binary_search import BinarySearch
print(BinarySearch(SearchingAlgorithmInput(list_to_search=[1, 2, 3], target=2)).target_index)
# Round rubin example
from falgopy.scheduling.algorithms.round_robin.round_robin import RoundRobin
from falgopy.scheduling.algorithms.round_robin.round_robin_input import RoundRobinInput
from falgopy.utils.models.task import Task
print(RoundRobin(RoundRobinInput(pool=[
Task(name="Task 1", remaining_time=10),
Task(name="Task 2", remaining_time=5),
Task(name="Task 3", remaining_time=3),
Task(name="Task 4", remaining_time=1),
])).algorithm_output.queue)
Algorithms
- Base classes (utils)
- Fundamentals ideas
- Variety of algorithms implementations
Abstract algorithm
class Algorithm:
def __init__(self, algorithm_input: AlgorithmInput):
@abstractmethod
def run(self) -> AlgorithmOutput:
def check_run_time(self):
Algorithms types
Search
Searching abstract algorithm
class SearchingAlgorithm(Algorithm):
def __init__(self, algorithm_input: SearchingAlgorithmInput):
@abstractmethod
def search(self) -> SearchingAlgorithmOutput:
def run(self) -> SearchingAlgorithmOutput:
"""
Run the algorithm
Returns: return searching algorithm output
"""
algoritm_output = self.search()
self.logger.info(f"Total iterations: {algoritm_output.total_search_iterations}")
return algoritm_output
Examples
- Binary search
Sort
Sorting abstract algorithm
class SortingAlgorithm(Algorithm):
def __init__(self, algorithm_input: SortingAlgorithmInput):
@abstractmethod
def get_sorted_list(self) -> SortingAlgorithmOutput:
def run(self) -> SortingAlgorithmOutput:
"""
Run the algorithm
Returns: yield next value in schedule
"""
return self.get_sorted_list()
Examples
- Binary Sort
- Bubble Sort
- Sort
Scheduling
Sorting abstract algorithm
class SchedulingAlgorithm(Algorithm):
def __init__(self, algorithm_input: SchedulingAlgorithmInput):
@abstractmethod
def is_done(self):
@abstractmethod
def schedule_next(self):
def run(self) -> SchedulingAlgorithmOutput:
"""
Run the algorithm
Returns: yield next value in schedule
"""
while not self.is_done():
self.schedule_next()
self.logger.info(
f"Pool: {self.algorithm_input.pool}, "
f"Queue: {self.algoritm_output.queue}, "
f"Total time: {self.algoritm_output.total_time}"
)
return self.algoritm_output
Examples
- Round Robin
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
falgopy-2.0.0.tar.gz
(8.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
falgopy-2.0.0-py3-none-any.whl
(17.9 kB
view details)
File details
Details for the file falgopy-2.0.0.tar.gz.
File metadata
- Download URL: falgopy-2.0.0.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ed92c823224c9334d53ca47ac7e6236d8f337d0210c8cca91dd6262b9bfdc02
|
|
| MD5 |
5393a4adb75b5e922f2c096e09fbc516
|
|
| BLAKE2b-256 |
396062040e213ffcb21cf50f916fd0395026bd2d8b285f6f592e1612e2ea7732
|
File details
Details for the file falgopy-2.0.0-py3-none-any.whl.
File metadata
- Download URL: falgopy-2.0.0-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66cf4d3d716569a7ee609b1609b6a9fc294f10232d619f37e8b58411e0e08175
|
|
| MD5 |
cade44cea7462506365110fa0d6d7769
|
|
| BLAKE2b-256 |
78aae30abda7f49c030feb925fad04bd2d35aa6d88d6dd140fc950d980ec2f3b
|