Functions | |
def | permute_range |
def | permute |
permute( nested_iterable ) -> permutation_genorator | |
Variables | |
string | __copyright__ |
string | __license__ |
permute( nested_iterable ) -> permutation_genorator
Takes a nested iterator sequence and returns all of the permutaions
eg. >>> pgen = permute( [[1,2], [3,4] ] ) >>> for permutaion in pgen: >>> print permutaion [1, 3] [1, 4] [2, 3] [2, 4]
>>> pgen = permute( dict( a=[1,2], b=[3] ) ) >>> for permutaion in pgen: >>> print permutaion { 'a':1, 'b':3 } { 'a':2, 'b':3 }
if constructor is not None, the output of each genoration is replaced by permutaion = constructor( permutaion )
if restrict is passed in it may be a callable function that evaluates a permutaion and returns True if the permutation needs to be restricted. if the first egample passing lambda perm: perm[0] == 2 will not generate permutations where permutaion[0] is 2 i.e. only [1, 3] and [1, 4] are generated
Definition at line 76 of file permute.py.
def slimpy_base.utils.permute.permute_range | ( | shape | ) |
Definition at line 39 of file permute.py.
string __copyright__ |
string __license__ |
Initial value:
""" This file is part of SLIMpy . SLIMpy is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SLIMpy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SLIMpy . If not, see <http://www.gnu.org/licenses/>. """
Definition at line 4 of file permute.py.