def generate_criteria(number, prefix='c', random_direction=False, names=None): crits = Criteria() for i in range(number): cid = names[i] if names is not None else "%s%d" % (prefix, i + 1) c = Criterion(cid) if random_direction is True: c.direction = random.choice([-1, 1]) crits.append(c) return crits
def generate_criteria(number, prefix = 'c', random_direction = False, names = None): crits = Criteria() for i in range(number): cid = names[i] if names is not None else "%s%d" % (prefix, i+1) c = Criterion(cid) if random_direction is True: c.direction = random.choice([-1, 1]) crits.append(c) return crits
def generate_criteria_msjp(number, prefix = 'c', random_direction = False, names = None, random_directions = None): crits = Criteria() if random_directions is None: for i in range(number): cid = names[i] if names is not None else "%s%d" % (prefix, i+1) c = Criterion(cid) if random_direction is True: c.direction = random.choice([-1, 1]) crits.append(c) else : # check for the size otherwise raise an error for i in range(number): cid = names[i] if names is not None else "%s%d" % (prefix, i+1) c = Criterion(cid) c.direction = random_directions[i] crits.append(c) return crits