Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #10 #12 #11

Merged
merged 3 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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