Skip to content

Commit

Permalink
switched to native python methods
Browse files Browse the repository at this point in the history
  • Loading branch information
andbag committed Aug 24, 2012
1 parent 5246fed commit 0fe477b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Products/PluginIndexes/CompositeIndex/util.py
Expand Up @@ -11,14 +11,17 @@
#
##############################################################################

from itertools import chain, combinations
from itertools import chain
from itertools import combinations
from itertools import product as cartesian_product

_marker = []

class PermuteKeywordList:
"""
class CartesianProduct:
""" Cartesian product of input iterables.
returns a flat list of a sequential
permutation of keyword lists.
Example:
A = [[1,2,3],[4,5],[6,7]]
Expand Down Expand Up @@ -95,7 +98,12 @@ def walking(self,A,f=_marker):



# since python 2.6 CartesianProduct class is obsolete
# itertools library provides a native function
def product(*args, **kwds):
return cartesian_product(*args, **kwds)

# adapted from http://docs.python.org/library/itertools.html#recipes
def powerset(iterable,start=0):
s = list(iterable)
return chain.from_iterable(combinations(s, r) for r in range(start,len(s)+1))

0 comments on commit 0fe477b

Please sign in to comment.