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.6 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
permutation-0.3.1.tar.gz
(16.9 kB
view hashes)
Built Distribution
Close
Hashes for permutation-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ee2eac807a6ac731a66e8158bd2f34b64e994dd6ed7e00e37e0f0ec8c4a4c87 |
|
MD5 | 5b6a5bd9619fd60713b3c229e7fec3bb |
|
BLAKE2b-256 | 33c059c617c13703e9f9342fa31bc9e388a5c0d7efe6ba0b698023a0f322bf4a |