Name | permutations JSON |
Version |
0.2.0
JSON |
| download |
home_page | |
Summary | Python library for instantiating and working with permutation collections that provide efficient implementations of all sequence methods (including random-access retrieval by index). |
upload_time | 2024-01-10 08:49:25 |
maintainer | |
docs_url | None |
author | Andrei Lapets |
requires_python | >=3.7 |
license | MIT |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
============
permutations
============
Python library for instantiating and working with permutation collections that provide efficient implementations of all sequence methods (including random-access retrieval by index).
|pypi| |readthedocs| |actions| |coveralls|
.. |pypi| image:: https://badge.fury.io/py/permutations.svg
:target: https://badge.fury.io/py/permutations
:alt: PyPI version and link.
.. |readthedocs| image:: https://readthedocs.org/projects/permutations/badge/?version=latest
:target: https://permutations.readthedocs.io/en/latest/?badge=latest
:alt: Read the Docs documentation status.
.. |actions| image:: https://github.com/lapets/permutations/workflows/lint-test-cover-docs/badge.svg
:target: https://github.com/lapets/permutations/actions/workflows/lint-test-cover-docs.yml
:alt: GitHub Actions status.
.. |coveralls| image:: https://coveralls.io/repos/github/lapets/permutations/badge.svg?branch=main
:target: https://coveralls.io/github/lapets/permutations?branch=main
:alt: Coveralls test coverage summary.
Purpose
-------
.. |itertools_permutations| replace:: ``itertools.permutations``
.. _itertools_permutations: https://docs.python.org/3/library/itertools.html#itertools.permutations
.. |Sequence| replace:: ``Sequence``
.. _Sequence: https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence
This library provides a drop-in alternative to the built-in |itertools_permutations|_ function. This alternative implements the features of a |Sequence|_, including the ability to access individual entries using their index (without iterating over all permutations up to that point).
Installation and Usage
----------------------
This library is available as a `package on PyPI <https://pypi.org/project/permutations>`__:
.. code-block:: bash
python -m pip install permutations
The library can be imported in the usual ways:
.. code-block:: python
import permutations
from permutations import permutations
Examples
^^^^^^^^
.. |permutations| replace:: ``permutations``
.. _permutations: https://permutations.readthedocs.io/en/0.2.0/_source/permutations.html#permutations.permutations.permutations
.. |Iterable| replace:: ``Iterable``
.. _Iterable: https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterable
The |permutations|_ class can be used in the same way as the built-in |itertools_permutations|_ function:
.. code-block:: python
>>> list(permutations(range(3)))
[(0, 1, 2), (0, 2, 1), (1, 0, 2), (1, 2, 0), (2, 0, 1), (2, 1, 0)]
>>> list(permutations(range(3), 2))
[(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)]
However, in addition to acting as an |Iterable|_ containing a collection of permutations, an instance of |permutations|_ also acts as a |Sequence|_. In particular, it supports retrieval of specific permutations by their index and its length can be determined without iterating over its elements:
.. code-block:: python
>>> ps = permutations(range(5))
>>> ps[37]
(1, 3, 0, 4, 2)
>>> permutations(range(20))[7**20]
(0, 13, 9, 6, 14, 8, 17, 1, 5, 12, 15, 18, 11, 16, 10, 2, 3, 4, 19, 7)
>>> len(permutations(range(8))) == 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1
True
Development
-----------
All installation and development dependencies are fully specified in ``pyproject.toml``. The ``project.optional-dependencies`` object is used to `specify optional requirements <https://peps.python.org/pep-0621>`__ for various development tasks. This makes it possible to specify additional options (such as ``docs``, ``lint``, and so on) when performing installation using `pip <https://pypi.org/project/pip>`__:
.. code-block:: bash
python -m pip install .[docs,lint]
Documentation
^^^^^^^^^^^^^
The documentation can be generated automatically from the source files using `Sphinx <https://www.sphinx-doc.org>`__:
.. code-block:: bash
python -m pip install .[docs]
cd docs
sphinx-apidoc -f -E --templatedir=_templates -o _source .. && make html
Testing and Conventions
^^^^^^^^^^^^^^^^^^^^^^^
All unit tests are executed and their coverage is measured when using `pytest <https://docs.pytest.org>`__ (see the ``pyproject.toml`` file for configuration details):
.. code-block:: bash
python -m pip install .[test]
python -m pytest
Alternatively, all unit tests are included in the module itself and can be executed using `doctest <https://docs.python.org/3/library/doctest.html>`__:
.. code-block:: bash
python src/permutations/permutations.py -v
Style conventions are enforced using `Pylint <https://pylint.readthedocs.io>`__:
.. code-block:: bash
python -m pip install .[lint]
python -m pylint src/permutations
Contributions
^^^^^^^^^^^^^
In order to contribute to the source code, open an issue or submit a pull request on the `GitHub page <https://github.com/lapets/permutations>`__ for this library.
Versioning
^^^^^^^^^^
The version number format for this library and the changes to the library associated with version number increments conform with `Semantic Versioning 2.0.0 <https://semver.org/#semantic-versioning-200>`__.
Publishing
^^^^^^^^^^
This library can be published as a `package on PyPI <https://pypi.org/project/permutations>`__ by a package maintainer. First, install the dependencies required for packaging and publishing:
.. code-block:: bash
python -m pip install .[publish]
Ensure that the correct version number appears in ``pyproject.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 an `automation rule <https://docs.readthedocs.io/en/stable/automation-rules.html>`__ that activates and sets as the default all tagged versions. Create and push a tag for this version (replacing ``?.?.?`` with the version number):
.. code-block:: bash
git tag ?.?.?
git push origin ?.?.?
Remove any old build/distribution files. Then, package the source into a distribution archive:
.. code-block:: bash
rm -rf build dist src/*.egg-info
python -m build --sdist --wheel .
Finally, upload the package distribution archive to `PyPI <https://pypi.org>`__:
.. code-block:: bash
python -m twine upload dist/*
Raw data
{
"_id": null,
"home_page": "",
"name": "permutations",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "",
"author": "Andrei Lapets",
"author_email": "a@lapets.io",
"download_url": "https://files.pythonhosted.org/packages/f7/06/8b2a789e6cbbe37c18fedc5b2c959aea9503d0bdbb3eee8a806ffdf38880/permutations-0.2.0.tar.gz",
"platform": null,
"description": "============\npermutations\n============\n\nPython library for instantiating and working with permutation collections that provide efficient implementations of all sequence methods (including random-access retrieval by index).\n\n|pypi| |readthedocs| |actions| |coveralls|\n\n.. |pypi| image:: https://badge.fury.io/py/permutations.svg\n :target: https://badge.fury.io/py/permutations\n :alt: PyPI version and link.\n\n.. |readthedocs| image:: https://readthedocs.org/projects/permutations/badge/?version=latest\n :target: https://permutations.readthedocs.io/en/latest/?badge=latest\n :alt: Read the Docs documentation status.\n\n.. |actions| image:: https://github.com/lapets/permutations/workflows/lint-test-cover-docs/badge.svg\n :target: https://github.com/lapets/permutations/actions/workflows/lint-test-cover-docs.yml\n :alt: GitHub Actions status.\n\n.. |coveralls| image:: https://coveralls.io/repos/github/lapets/permutations/badge.svg?branch=main\n :target: https://coveralls.io/github/lapets/permutations?branch=main\n :alt: Coveralls test coverage summary.\n\nPurpose\n-------\n\n.. |itertools_permutations| replace:: ``itertools.permutations``\n.. _itertools_permutations: https://docs.python.org/3/library/itertools.html#itertools.permutations\n\n.. |Sequence| replace:: ``Sequence``\n.. _Sequence: https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence\n\nThis library provides a drop-in alternative to the built-in |itertools_permutations|_ function. This alternative implements the features of a |Sequence|_, including the ability to access individual entries using their index (without iterating over all permutations up to that point).\n\nInstallation and Usage\n----------------------\nThis library is available as a `package on PyPI <https://pypi.org/project/permutations>`__:\n\n.. code-block:: bash\n\n python -m pip install permutations\n\nThe library can be imported in the usual ways:\n \n.. code-block:: python\n\n import permutations\n from permutations import permutations\n\nExamples\n^^^^^^^^\n\n.. |permutations| replace:: ``permutations``\n.. _permutations: https://permutations.readthedocs.io/en/0.2.0/_source/permutations.html#permutations.permutations.permutations\n\n.. |Iterable| replace:: ``Iterable``\n.. _Iterable: https://docs.python.org/3/library/collections.abc.html#collections.abc.Iterable\n\nThe |permutations|_ class can be used in the same way as the built-in |itertools_permutations|_ function:\n\n.. code-block:: python\n\n >>> list(permutations(range(3)))\n [(0, 1, 2), (0, 2, 1), (1, 0, 2), (1, 2, 0), (2, 0, 1), (2, 1, 0)]\n >>> list(permutations(range(3), 2))\n [(0, 1), (0, 2), (1, 0), (1, 2), (2, 0), (2, 1)]\n\nHowever, in addition to acting as an |Iterable|_ containing a collection of permutations, an instance of |permutations|_ also acts as a |Sequence|_. In particular, it supports retrieval of specific permutations by their index and its length can be determined without iterating over its elements:\n\n.. code-block:: python\n\n >>> ps = permutations(range(5))\n >>> ps[37]\n (1, 3, 0, 4, 2)\n >>> permutations(range(20))[7**20]\n (0, 13, 9, 6, 14, 8, 17, 1, 5, 12, 15, 18, 11, 16, 10, 2, 3, 4, 19, 7)\n >>> len(permutations(range(8))) == 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1\n True\n\nDevelopment\n-----------\nAll installation and development dependencies are fully specified in ``pyproject.toml``. The ``project.optional-dependencies`` object is used to `specify optional requirements <https://peps.python.org/pep-0621>`__ for various development tasks. This makes it possible to specify additional options (such as ``docs``, ``lint``, and so on) when performing installation using `pip <https://pypi.org/project/pip>`__:\n\n.. code-block:: bash\n\n python -m pip install .[docs,lint]\n\nDocumentation\n^^^^^^^^^^^^^\nThe documentation can be generated automatically from the source files using `Sphinx <https://www.sphinx-doc.org>`__:\n\n.. code-block:: bash\n\n python -m pip install .[docs]\n cd docs\n sphinx-apidoc -f -E --templatedir=_templates -o _source .. && make html\n\nTesting and Conventions\n^^^^^^^^^^^^^^^^^^^^^^^\nAll unit tests are executed and their coverage is measured when using `pytest <https://docs.pytest.org>`__ (see the ``pyproject.toml`` file for configuration details):\n\n.. code-block:: bash\n\n python -m pip install .[test]\n python -m pytest\n\nAlternatively, all unit tests are included in the module itself and can be executed using `doctest <https://docs.python.org/3/library/doctest.html>`__:\n\n.. code-block:: bash\n\n python src/permutations/permutations.py -v\n\nStyle conventions are enforced using `Pylint <https://pylint.readthedocs.io>`__:\n\n.. code-block:: bash\n\n python -m pip install .[lint]\n python -m pylint src/permutations\n\nContributions\n^^^^^^^^^^^^^\nIn order to contribute to the source code, open an issue or submit a pull request on the `GitHub page <https://github.com/lapets/permutations>`__ for this library.\n\nVersioning\n^^^^^^^^^^\nThe version number format for this library and the changes to the library associated with version number increments conform with `Semantic Versioning 2.0.0 <https://semver.org/#semantic-versioning-200>`__.\n\nPublishing\n^^^^^^^^^^\nThis library can be published as a `package on PyPI <https://pypi.org/project/permutations>`__ by a package maintainer. First, install the dependencies required for packaging and publishing:\n\n.. code-block:: bash\n\n python -m pip install .[publish]\n\nEnsure that the correct version number appears in ``pyproject.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 an `automation rule <https://docs.readthedocs.io/en/stable/automation-rules.html>`__ that activates and sets as the default all tagged versions. Create and push a tag for this version (replacing ``?.?.?`` with the version number):\n\n.. code-block:: bash\n\n git tag ?.?.?\n git push origin ?.?.?\n\nRemove any old build/distribution files. Then, package the source into a distribution archive:\n\n.. code-block:: bash\n\n rm -rf build dist src/*.egg-info\n python -m build --sdist --wheel .\n\nFinally, upload the package distribution archive to `PyPI <https://pypi.org>`__:\n\n.. code-block:: bash\n\n python -m twine upload dist/*\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python library for instantiating and working with permutation collections that provide efficient implementations of all sequence methods (including random-access retrieval by index).",
"version": "0.2.0",
"project_urls": {
"Documentation": "https://permutations.readthedocs.io",
"Repository": "https://github.com/lapets/permutations"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a4bd31451283c446cb6afba40dbddf3a229814fd9b340874d9223a8f5df2d7f0",
"md5": "d63ca23994e94e3cd59b42e79dd22359",
"sha256": "0cde6657dec5b6d64724aa0925d79cf9c53768a648b9535f2bda82a4b28cdb4e"
},
"downloads": -1,
"filename": "permutations-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d63ca23994e94e3cd59b42e79dd22359",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 6583,
"upload_time": "2024-01-10T08:49:24",
"upload_time_iso_8601": "2024-01-10T08:49:24.034177Z",
"url": "https://files.pythonhosted.org/packages/a4/bd/31451283c446cb6afba40dbddf3a229814fd9b340874d9223a8f5df2d7f0/permutations-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f7068b2a789e6cbbe37c18fedc5b2c959aea9503d0bdbb3eee8a806ffdf38880",
"md5": "ecce36b1c3bd5f4cbe834550bcb32925",
"sha256": "13cf5902f431c97344ccbf7e57aa59b2706f942a2128e8de9c54f5d743463d3e"
},
"downloads": -1,
"filename": "permutations-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "ecce36b1c3bd5f4cbe834550bcb32925",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 6426,
"upload_time": "2024-01-10T08:49:25",
"upload_time_iso_8601": "2024-01-10T08:49:25.763965Z",
"url": "https://files.pythonhosted.org/packages/f7/06/8b2a789e6cbbe37c18fedc5b2c959aea9503d0bdbb3eee8a806ffdf38880/permutations-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-10 08:49:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "lapets",
"github_project": "permutations",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "permutations"
}