MCPcopy
hub / github.com/larsenwork/monoid / permutations

Function permutations

Scripts/fontbuilder.py:51–65  ·  view source on GitHub ↗

Yields all possible permutations from the options list

()

Source from the content-addressed store, hash-verified

49 return expanded
50
51def permutations():
52 """Yields all possible permutations from the options list"""
53 count = len(option.abrvs)
54
55 # Each option is a binary choice, so we use an int as a quick bitmap.
56 # To iterate over every possible permutation, all we have to do is increment
57 # up to the maximum value 2^(#options)
58 bitmap_max = 1 << count
59
60 # Iterate over all possible permutations
61 for i in xrange(bitmap_max):
62 # Map the iteration's permutations using a bitmap
63 bitmap = [i >> n & 1 for n in xrange(count)]
64 for opts in _expand_options(bitmap):
65 yield(int(float(i)/bitmap_max*100), opts)
66
67def _build(dstdir, font, permutations):
68 # Ensure that the destination directory exists

Callers 2

buildFunction · 0.85
build_batchFunction · 0.85

Calls 1

_expand_optionsFunction · 0.85

Tested by

no test coverage detected