Skip to main content

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

result = BinarySearch(SearchingAlgorithmInput(list_to_search=[1, 2, 3], target=2)).run()
print(result.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

result = 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),
        ],
        time_slice=6)
).run()

print(result.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-3.0.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

falgopy-3.0.0-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file falgopy-3.0.0.tar.gz.

File metadata

  • Download URL: falgopy-3.0.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for falgopy-3.0.0.tar.gz
Algorithm Hash digest
SHA256 87c55d18c694dee6b497d757c8b8a1d489054bee84e165dfdfa5ce8b07a46643
MD5 5aae7a6ae8a484bab61d72a3ff499b1a
BLAKE2b-256 9574f0dbe373be219b1f7bc8acd7795a22e5f16e6903af5f9285c3cdef7c4c7b

See more details on using hashes here.

File details

Details for the file falgopy-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: falgopy-3.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

Hashes for falgopy-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 11da61d2b2c95efa1ec919e428940e8da7e7fe4eb3e52cbbf8f105d9c7e8a0a3
MD5 b5f48908ed652781e70f5cce9715e944
BLAKE2b-256 3cde5eea93c02e8c56a5bb039be1d148054bb699609ba54ef6b075232e06f0c6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page