diff --git a/common/lib/xmodule/xmodule/abtest_module.py b/common/lib/xmodule/xmodule/abtest_module.py index bb55fa7ee8..035413a402 100644 --- a/common/lib/xmodule/xmodule/abtest_module.py +++ b/common/lib/xmodule/xmodule/abtest_module.py @@ -11,18 +11,19 @@ DEFAULT = "_DEFAULT_GROUP" def group_from_value(groups, v): - ''' Given group: (('a',0.3),('b',0.4),('c',0.3)) And random value + """ + Given group: (('a', 0.3), ('b', 0.4), ('c', 0.3)) and random value v in [0,1], return the associated group (in the above case, return - 'a' if v<0.3, 'b' if 0.3<=v<0.7, and 'c' if v>0.7 -''' + 'a' if v < 0.3, 'b' if 0.3 <= v < 0.7, and 'c' if v > 0.7 + """ sum = 0 for (g, p) in groups: sum = sum + p if sum > v: return g - # Round off errors might cause us to run to the end of the list - # If the do, return the last element + # Round off errors might cause us to run to the end of the list. + # If the do, return the last element. return g