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.7 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.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
File details
Details for the file permutation-0.4.0.tar.gz
.
File metadata
- Download URL: permutation-0.4.0.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d33e2c90ea26c6d6dc85be14dfd78900bcce5d4c1b43363660a0b7f3bc05d32 |
|
MD5 | b90d92011f97836022490346a474db1b |
|
BLAKE2b-256 | aff6e35627cd311d74413c0409296b4a4e7b48a745284f7765174acb080d0b36 |
File details
Details for the file permutation-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: permutation-0.4.0-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43ef27c651153f16887b88b2398bb0cce6f8bc3068f1cfd3a31dc339fb2b5ac4 |
|
MD5 | 95955e95ba732f81f68fc1ebfe240398 |
|
BLAKE2b-256 | 0e10b9d0c5dea6e3f3904b409a2237404ff480a779e5bd99edc5304eaa0b2deb |