Skip to main content

Democritus functions for working with algorithms.

Project description

Democritus Algorithms (a.k.a. d8s-algorithms)

PyPI CI Lint codecov The Democritus Project uses semver version 2.0.0 The Democritus Project uses ruff to format and lint code License: LGPL v3

Democritus functions[1] for working with algorithms.

[1] Democritus functions are simple, effective, modular, well-tested, and well-documented Python functions.

We use d8s (pronounced "dee-eights") as an abbreviation for democritus (you can read more about this here).

Installation

pip install d8s-algorithms

Usage

You import the library like:

from d8s_algorithms import *

Once imported, you can use any of the functions listed below.

Functions

  • def amb(validation_function: Callable[..., bool], *args: Any) -> Iterable[Any]:
        """."""
    
  • def depth_first_traverse(
        data: Any,
        get_children_function: Callable[[Any], Optional[Iterable]],
        *,
        collect_items_function: Optional[Callable[[Any], Any]] = None
    ) -> Iterable[Any]:
        """Traverse the data in a depth-first manner.
    
    The get_children_function specifies how children will be identified from each node of the data.
    The collect_items_function, if provided, allows you to collect items from the data by...
     returning them from the collect_items_function."""
    
  • def breadth_first_traverse(
        data: Any,
        get_children_function: Callable[[Any], Optional[Iterable]],
        *,
        collect_items_function: Optional[Callable[[Any], Any]] = None
    ) -> Iterable[Any]:
        """Traverse the data in a breadth-first manner.
    
    The get_children_function specifies how children will be identified from each node of the data.
    The collect_items_function, if provided, allows you to collect items from the data by...
     returning them from the collect_items_function."""
    
  • def genetic_algorithm_run(
        data: Iterable[Any],
        scoring_function: Callable[[Any], Union[int, float]],
        selection_function: Callable[[Dict[Any, Union[int, float]]], Iterable[Any]],
        mutation_function: Callable[[Iterable[Any]], Iterable[Any]],
        max_epochs: int,
    ) -> Dict[Any, Union[int, float]]:
        """."""
    
  • def genetic_algorithm_best_mutation_function(
        starting_values: Iterable[Any],
        generations: int,
        scoring_function: Callable[[Any], Union[int, float]],
        mutation_functions: List[Callable[[Any], Any]],
    ):
        """Find the best mutation function.
    
    The best function is the one which produces values from the starting values...
     that score the highest (as measured by the scoring_function) after generations."""
    

Development

👋  If you want to get involved in this project, we have some short, helpful guides below:

If you have any questions or there is anything we did not cover, please raise an issue and we'll be happy to help.

Credits

This package was created with Cookiecutter and Floyd Hightower's Python project template.

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

d8s_algorithms-0.8.0.tar.gz (91.3 kB view details)

Uploaded Source

Built Distribution

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

d8s_algorithms-0.8.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file d8s_algorithms-0.8.0.tar.gz.

File metadata

  • Download URL: d8s_algorithms-0.8.0.tar.gz
  • Upload date:
  • Size: 91.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for d8s_algorithms-0.8.0.tar.gz
Algorithm Hash digest
SHA256 cc676a8c23294618690dbf346040a06e780538cd1f0b0426ac713b0268c0a196
MD5 c57b550d79f3ab3b05396e707335d82c
BLAKE2b-256 bc0b4c234114dc4ae26f1171dd7c8b92b7b974bea80d727becaf8e54ed65ff66

See more details on using hashes here.

Provenance

The following attestation bundles were made for d8s_algorithms-0.8.0.tar.gz:

Publisher: release-please.yml on democritus-project/d8s-algorithms

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file d8s_algorithms-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: d8s_algorithms-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for d8s_algorithms-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b8305ab75381d87374026264846227d04cb3ce61d71d7da572666f246dfecac
MD5 5c61e7c07f5ca2dd0f78c1cc2caa383c
BLAKE2b-256 f0b19b49b53d9582e48f5247f861c78c1b5fe4917d28de4ead9b1963089ec733

See more details on using hashes here.

Provenance

The following attestation bundles were made for d8s_algorithms-0.8.0-py3-none-any.whl:

Publisher: release-please.yml on democritus-project/d8s-algorithms

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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