Skip to main content

Project Status: Active — The project has reached a stable, usable state and is being actively developed. CI Status coverage pyversions 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)

Metadata

Release files for permutation 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for permutation 0.5.0
File Size Uploaded
permutation-0.5.0.tar.gz 16.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for permutation 0.5.0
File Interpreter ABI Platform
permutation-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.9 kB

Release files / permutation-0.5.0.tar.gz

Download URL permutation-0.5.0.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
568b94f68a466f424f7d18f3d5c6dee2ffad8052d4ad9ae5caae7c9a6ee0fbd7
BLAKE2b-256 checksum
How to use checksums
f34cb74d01cc99b8e2f13d77212e2b3a28966c70b09fd4963d5ad2e35a4df414
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.13.0

Release files / permutation-0.5.0-py3-none-any.whl

Download URL permutation-0.5.0-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e73566dd6cf337b158a281eb318bb57dc29ceace3e952242b746c9270b3c0ad8
BLAKE2b-256 checksum
How to use checksums
e772f0fbf48e0bfe09a2451e92ea03fdd988d0be39c5508b063415a71b1fac4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.13.0

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page