Package: combi
Combi is a Pythonic package forcombinatorics.Combi lets you explore spaces ofpermutationsandcombinationsas 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/combiCombi on PyPI:https://pypi.python.org/pypi/combiChangelog:https://combi.readthedocs.org/en/stable/changelog.htmlBasic usageUsePermSpaceto create a permutation space:>>>fromcombiimport*>>>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')3And yet the permutations are created on-demand rather than in advance.UseCombSpaceto 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)3For more details,try the tutorialor see thedocumentation contents.FeaturesPermSpacelets 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.PermSpacewill 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-permutationsare supported.You may specify a custom type for the generated permutations, so you could
implement your own functionality on them.CombSpacelets you explore a space of combinations as if it was a
Python sequence.MapSpaceis like Python’s built-inmap, except it’s a
sequence that allows index access.ProductSpaceis like Python’sitertools.product, except
it’s a sequence that allows index access.ChainSpaceis like Python’sitertools.chain, except
it’s a sequence that allows index access.SelectionSpaceis a space of all selections from a sequence, of all
possible lengths.TheBagclass is a multiset like Python’scollections.Counter, except
it offers far more functionality, like morearithmetic operations between
bags,comparison between bags, and more. (It can do that because unlike
Python’scollections.Counter, it only allows natural numbers as keys.)ClassesFrozenBag,OrderedBagandFrozenOrderedBagare provided,
which are variations onBag.RequirementsPython, version 2.6, 2.7 or 3.3 or above. If you’re new to Python,download
the newest version from here.Setuptools.InstallationUsepipto install Combi:$pipinstallcombiCommunityCombi on GitHub:https://github.com/cool-RR/combiFeel free to fork and send
pull requests!There are three Combi groups, a.k.a. mailing lists:If you need help with Combi, post a message onthe combi-users
Google Group.If you want to help on the development of Combi itself, come say
hello onthe combi-dev Google Group.If you want to be informed on new releases of Combi, sign up forthe low-traffic combi-announce Google Group.Combi was created by Ram Rachum. I provideDevelopment services in Python and Django.