Skip to main content

Combi is a Pythonic package for combinatorics.

Combi lets you explore spaces of permutations and combinations as if they were Python sequences, but without generating all the permutations/combinations in advance. It lets you specify a lot of special conditions on these spaces. It also provides a few more classes that might be useful in combinatorics programming.

Combi documentation: https://combi.readthedocs.org/en/stable/

Combi on GitHub: https://github.com/cool-RR/combi

Combi on PyPI: https://pypi.python.org/pypi/combi

Changelog: https://combi.readthedocs.org/en/stable/changelog.html

Basic usage

Use PermSpace to create a permutation space:

>>> from combi import *
>>> perm_space = PermSpace('meow')

It behaves like a sequence:

>>> len(perm_space)
24
>>> perm_space[7]
<Perm: ('e', 'm', 'w', 'o')>
>>> perm_space.index('mowe')
3

And yet the permutations are created on-demand rather than in advance.

Use CombSpace to create a combination space, where order doesn’t matter:

>>> comb_space = CombSpace(('vanilla', 'chocolate', 'strawberry'), 2)
>>> comb_space
<CombSpace: ('vanilla', 'chocolate', 'strawberry'), n_elements=2>
>>> comb_space[2]
<Comb, n_elements=2: ('chocolate', 'strawberry')>
>>> len(comb_space)
3

For more details, try the tutorial or see the documentation contents.

Features

  • PermSpace lets you explore a space of permutations as if it was a Python sequence.

    • Permutations are generated on-demand, so huge permutation spaces can be created easily without big memory footprint.

    • PermSpace will notice if you have repeating elements in your sequence, and treat all occurences of the same value as interchangable rather than create redundant permutations.

    • A custom domain can be specified instead of just using index numbers.

    • You may specify some elements to be fixed, so they’ll point to the same value in all permutations. (Useful for limiting an experiment to a subset of the original permutation space.)

    • Permutation spaces may be limited to a certain degree of permutations. (A permutation’s degree is the number of transformations it takes to make it.)

    • k-permutations are supported.

    • You may specify a custom type for the generated permutations, so you could implement your own functionality on them.

  • CombSpace lets you explore a space of combinations as if it was a Python sequence.

  • MapSpace is like Python’s built-in map, except it’s a sequence that allows index access.

  • ProductSpace is like Python’s itertools.product, except it’s a sequence that allows index access.

  • ChainSpace is like Python’s itertools.chain, except it’s a sequence that allows index access.

  • SelectionSpace is a space of all selections from a sequence, of all possible lengths.

  • The Bag class is a multiset like Python’s collections.Counter, except it offers far more functionality, like more arithmetic operations between bags, comparison between bags, and more. (It can do that because unlike Python’s collections.Counter, it only allows natural numbers as keys.)

  • Classes FrozenBag, OrderedBag and FrozenOrderedBag are provided, which are variations on Bag.

Requirements

Installation

Use pip to install Combi:

$ pip install combi

Community

Combi on GitHub: https://github.com/cool-RR/combi Feel free to fork and send pull requests!

There are three Combi groups, a.k.a. mailing lists:


Combi was created by Ram Rachum. I provide Development services in Python and Django.

Metadata

Release files for combi 1.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for combi 1.1.4
File Size Uploaded
combi-1.1.4.tar.gz 716.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for combi 1.1.4
File Interpreter ABI Platform
combi-1.1.4-py3-none-any.whl Python 3 none any Details
combi-1.1.4-py2-none-any.whl Python 2 none any Details

Total release size: 1.3 MB

Release files / combi-1.1.4.tar.gz

Download URL combi-1.1.4.tar.gz
Size 716.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e039296deb4cdb250ce451cbf443fa66336243a10329355422ac78e94a35c3c7
BLAKE2b-256 checksum
How to use checksums
e240c924f4d087ea43b25ba7c72c7e45da509d819a089cf053d87920b962391a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1

Release files / combi-1.1.4-py3-none-any.whl

Download URL combi-1.1.4-py3-none-any.whl
Size 250.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9875554f9fbe34aa349e390fd6897a52508006582a11f0b907895d85c1e24a6d
BLAKE2b-256 checksum
How to use checksums
3d4e06b8dc3733eee9ebffde5522c52b18d6ab73fca31ac57f731a165c860b2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1

Release files / combi-1.1.4-py2-none-any.whl

Download URL combi-1.1.4-py2-none-any.whl
Size 310.7 kB
Tags Python 2
SHA-256 checksum
How to use checksums
449e38e76eb80ee88d80ee491a423f8bdb57287b62c751d184a13b4b6a5f122f
BLAKE2b-256 checksum
How to use checksums
8bb123b88803834a316ed3f4336b3e13ee4b4153592a7a0d0cc430d019634762
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.1

Release history Release notifications | RSS feed

This release

1.1.4 This release

3 release files

1.1.3

1.1.2

3 release files

1.1.1

3 release files

1.1.0

3 release files

1.0.0

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page