Commit 564168c3 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Compute combinations of arrays

parent 08698895
......@@ -2,7 +2,7 @@
# Resource object code
#
# Created: Sun Mar 22 21:50:51 2015
# Created: Mon Mar 23 22:08:12 2015
# by: The Resource Compiler for PySide (Qt v4.8.6)
#
# WARNING! All changes made in this file will be lost!
......
......@@ -84,9 +84,14 @@ def compute_combinations(asn1_ty, pool):
yield each
def compute_integer_combinations(asn1_ty):
''' Generator returning all combinations of integer '''
for each in xrange(int(asn1_ty.Min), int(asn1_ty.Max)):
def compute_integer_combinations(asn1_ty, max_iter=None):
''' Generator returning all integer values, with optional limit '''
# Do not use xrange, it needs a value that fits in a C long
max_iter = (long(asn1_ty.Min)
+ max_iter) if max_iter != 0 else long(asn1_ty.Max)
for each in itertools.count(long(asn1_ty.Min)):
if each == max_iter:
break
yield str(each)
......@@ -132,7 +137,12 @@ def compute_sequence_combinations(asn1_ty, pool):
def compute_sequenceof_combinations(asn1_ty, pool):
''' Generator returning all combinations of arrays '''
pass
for size in xrange(int(asn1_ty.Min), int(asn1_ty.Max)):
elems = []
for _ in xrange(size):
elems.append(compute_combinations(asn1_ty, pool))
for each in itertools.product(*elems):
yield '{{ {} }}'.format(', '.join(each))
class SendTC(QUndoCommand):
......@@ -484,10 +494,10 @@ class sdlHandler(QObject):
param or ''))
self.check_properties(new_hash)
# TEMP TO TEST
# for name, typedef in self.proc.dataview.viewitems():
# print 'All combinations of ', name
# for combi in compute_combinations(typedef, self.proc.dataview):
# print combi
# for name, typedef in self.proc.dataview.viewitems():
# print 'All combinations of ', name
# for combi in compute_combinations(typedef, self.proc.dataview):
# print combi
# END TEMP
return new_hash
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment