Skip to content

Commit

Permalink
Merge pull request #11 from clarksmr/master
Browse files Browse the repository at this point in the history
Fixes #10 #12
  • Loading branch information
tdimiduk authored Sep 13, 2021
2 parents d04c747 + 8410499 commit 28da195
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def run(input_deck):
sizer = sizer_from_dek(dek)
log.debug(sizer)

if dek_rules[0]['name'] == 'aggregate':
if len(dek_rules) > 0 and dek_rules[0]['name'] == 'aggregate':
attribute = dek_rules[0]['attribute']
# Turn back into a list to make sure ordering is preserved when we use
# this in multiple places
Expand Down
6 changes: 3 additions & 3 deletions src/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,14 @@ def get_strength(self, s):
def __str__(self):
return "<Balance : {0} : tol {1}>".format(self.mean, self.tol)
def _check(self, students):
try:
try:
return abs(utility.mean(students, self.get_strength) - self.mean) < self.tol
# If somehow you don't have a strength for any of the students,
# consider the group to be failing the rule
except EmptyMean:
return False
def permissable_change(self, old, new):
try:
try:
b = (abs(utility.mean(old, self.get_strength) - self.mean) >
abs(utility.mean(new, self.get_strength) - self.mean))
except EmptyMean:
Expand Down Expand Up @@ -503,7 +503,7 @@ def apply_rule(rule, groups, students, tries, mixing, try_number=0):
# finding new solutions
for i in range(mixing):
find_target_and_swap(random.choice(students), groups)
return apply_rule(rule, groups, students, try_number+1, tries, mixing)
return apply_rule(rule, groups, students, tries, mixing, try_number+1)
else:
return False
else:
Expand Down

0 comments on commit 28da195

Please sign in to comment.