Package: algebraical
Subclass of thebuilt-in function typefor representing algebraic operators (that are typically associated with algebraic structures and algebraic circuits) as immutable, hashable, sortable, and callable objects.This library is compatible with thecircuitlibrary and is intended to complement thelogicallibrary for logical operations.Installation and UsageThis library is available as apackage on PyPI:python -m pip install algebraicalThe library can be imported in the usual ways:import algebraical
from algebraical import *ExamplesEach instance of thealgebraicalclass (derived from the type of the built-in functions found in the built-inoperatorlibrary) represents a function that operates on values of typical algebraic structures (such asnumerictypes and any classes that define thespecial methodsassociated with these built-in operators):>>> from algebraical import algebraical
>>> algebraical.add_(1, 2)
3Methods for retrieving the name and arity of analgebraicalinstance are provided:>>> algebraical.add_.name()
'add'
>>> algebraical.add_.arity()
2Instances ofalgebraicalcan be compared according to their precedence:>>> algebraical.pow_ > algebraical.mul_
True
>>> algebraical.pow_ <= algebraical.add_
False
>>> sorted([pow_, mul_, add_] # From lowest to highest precedence.
[add_, mul_, pow_]Instances are also hashable and can be used as members ofsetsand as keys withindictionaries:>>> from algebraical import *
>>> {add_, mul_}
{mul_, add_}
>>> {add_: 0, mul_: 1}
{add_: 0, mul_: 1}DevelopmentAll installation and development dependencies are fully specified inpyproject.toml. Theproject.optional-dependenciesobject is used tospecify optional requirementsfor various development tasks. This makes it possible to specify additional options (such asdocs,lint, and so on) when performing installation usingpip:python -m pip install .[docs,lint]DocumentationThe documentation can be generated automatically from the source files usingSphinx:python -m pip install .[docs]
cd docs
sphinx-apidoc -f -E --templatedir=_templates -o _source .. && make htmlTesting and ConventionsAll unit tests are executed and their coverage is measured when usingpytest(see thepyproject.tomlfile for configuration details):python -m pip install .[test]
python -m pytestAlternatively, all unit tests are included in the module itself and can be executed usingdoctest:python src/algebraical/algebraical.py -vStyle conventions are enforced usingPylint:python -m pip install .[lint]
python -m pylint src/algebraicalContributionsIn order to contribute to the source code, open an issue or submit a pull request on theGitHub pagefor this library.VersioningThe version number format for this library and the changes to the library associated with version number increments conform withSemantic Versioning 2.0.0.PublishingThis library can be published as apackage on PyPIby a package maintainer. First, install the dependencies required for packaging and publishing:python -m pip install .[publish]Ensure that the correct version number appears inpyproject.toml, and that any links in this README document to the Read the Docs documentation of this package (or its dependencies) have appropriate version numbers. Also ensure that the Read the Docs project for this library has anautomation rulethat activates and sets as the default all tagged versions. Create and push a tag for this version (replacing?.?.?with the version number):git tag ?.?.?
git push origin ?.?.?Remove any old build/distribution files. Then, package the source into a distribution archive:rm -rf build dist src/*.egg-info
python -m build --sdist --wheel .Finally, upload the package distribution archive toPyPI:python -m twine upload dist/*