Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jwodder/permutation
Permutations of finitely many positive integers
https://github.com/jwodder/permutation
available-on-pypi group-theory math mathematics maths permutation python symmetric-group
Last synced: 24 days ago
JSON representation
Permutations of finitely many positive integers
- Host: GitHub
- URL: https://github.com/jwodder/permutation
- Owner: jwodder
- License: mit
- Created: 2017-09-02T20:22:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-12-01T12:58:42.000Z (about 1 month ago)
- Last Synced: 2024-12-09T18:11:44.748Z (about 1 month ago)
- Topics: available-on-pypi, group-theory, math, mathematics, maths, permutation, python, symmetric-group
- Language: Python
- Size: 139 KB
- Stars: 16
- Watchers: 3
- Forks: 5
- Open Issues: 13
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
|repostatus| |ci-status| |coverage| |pyversions| |license|
.. |repostatus| image:: https://www.repostatus.org/badges/latest/active.svg
:target: https://www.repostatus.org/#active
:alt: Project Status: Active — The project has reached a stable, usable
state and is being actively developed... |ci-status| image:: https://github.com/jwodder/permutation/actions/workflows/test.yml/badge.svg
:target: https://github.com/jwodder/permutation/actions/workflows/test.yml
:alt: CI Status.. |coverage| image:: https://codecov.io/gh/jwodder/permutation/branch/master/graph/badge.svg
:target: https://codecov.io/gh/jwodder/permutation.. |pyversions| image:: https://img.shields.io/pypi/pyversions/permutation.svg
:target: https://pypi.org/project/permutation.. |license| image:: https://img.shields.io/github/license/jwodder/permutation.svg
:target: https://opensource.org/licenses/MIT
:alt: MIT License`GitHub `_
| `PyPI `_
| `Documentation `_
| `Issues `_
| `Changelog `_``permutation`` provides a ``Permutation`` class for representing `permutations
`_ of finitely many positive
integers in Python. Supported operations & properties include inverses, (group
theoretic) order, parity, composition/multiplication, cycle decomposition,
cycle notation, word representation, Lehmer codes, and, of course, use as a
callable on integers.Installation
============
``permutation`` requires Python 3.8 or higher. Just use `pip
`_ for Python 3 (You have pip, right?) to install::python3 -m pip install permutation
Examples
========>>> from permutation import Permutation
>>> p = Permutation(2, 1, 4, 5, 3)
>>> p(1)
2
>>> p(3)
4
>>> p(42)
42
>>> p.to_cycles()
[(1, 2), (3, 4, 5)]
>>> print(p)
(1 2)(3 4 5)
>>> print(p.inverse())
(1 2)(3 5 4)
>>> p.degree
5
>>> p.order
6
>>> p.is_even
False
>>> p.lehmer(5)
27
>>> q = Permutation.cycle(1,2,3)
>>> print(p * q)
(2 4 5 3)
>>> print(q * p)
(1 3 4 5)
>>> for p in Permutation.group(3):
... print(p)
...
1
(1 2)
(2 3)
(1 3 2)
(1 2 3)
(1 3)