Permutations of finitely many positive integers
Project description
GitHub | PyPI | Documentation | Issues
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 is written in pure Python with no dependencies. Just use pip (You have pip, right?) to install:
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.1.1.tar.gz
(13.7 kB
view hashes)
Built Distribution
Close
Hashes for permutation-0.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5900dbb41bd6ad67310958fc8f95e9341e23c94ec9ff6d0f6a00687862e93583 |
|
MD5 | aacb4014ca89886bf30de969c5aca1e5 |
|
BLAKE2b-256 | 753bb227fa18233769e45190940c78c355ac7f63edb264b870b43070445da62d |