Skip to main content

Permutations of finitely many positive integers

Project description

Project Status: Active — The project has reached a stable, usable state and is being actively developed. https://travis-ci.org/jwodder/permutation.svg?branch=master https://coveralls.io/repos/github/jwodder/permutation/badge.svg?branch=master https://codecov.io/gh/jwodder/permutation/branch/master/graph/badge.svg https://img.shields.io/pypi/pyversions/permutation.svg MIT License

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.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

permutation-0.1.0-py2.py3-none-any.whl (10.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file permutation-0.1.0.tar.gz.

File metadata

  • Download URL: permutation-0.1.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for permutation-0.1.0.tar.gz
Algorithm Hash digest
SHA256 93af8e53c3f1c8616df7d7040f0cad9f5b82ba4ee13130c25842f6db9c80007c
MD5 d0eff9aba6854ed8c712c77555595dfa
BLAKE2b-256 aa781e3e66fc25dd98977a2329d1dd1e5a3d8a45598fccd4df03fcbabd8de253

See more details on using hashes here.

File details

Details for the file permutation-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for permutation-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 178696c8e4be2d591a10b9523f22092be8bf2dc84a97af82fbc523fd2d8adf48
MD5 4ba5eba838b8e0db61b9c089ee1fea32
BLAKE2b-256 a6e6018f6b92f89feddba6f7b919864fb2d9198311713e407e76ac75d5573319

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page