Permutations of finitely many positive integers
Project description
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)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file permutation-0.5.0.tar.gz.
File metadata
- Download URL: permutation-0.5.0.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
568b94f68a466f424f7d18f3d5c6dee2ffad8052d4ad9ae5caae7c9a6ee0fbd7
|
|
| MD5 |
55f7223f110ab19bbcf118d4eebb9f73
|
|
| BLAKE2b-256 |
f34cb74d01cc99b8e2f13d77212e2b3a28966c70b09fd4963d5ad2e35a4df414
|
File details
Details for the file permutation-0.5.0-py3-none-any.whl.
File metadata
- Download URL: permutation-0.5.0-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e73566dd6cf337b158a281eb318bb57dc29ceace3e952242b746c9270b3c0ad8
|
|
| MD5 |
78846260f37741ed00635a36ac8e9319
|
|
| BLAKE2b-256 |
e772f0fbf48e0bfe09a2451e92ea03fdd988d0be39c5508b063415a71b1fac4b
|