Commit d8a1184a authored by Florian Wohner's avatar Florian Wohner
Browse files

update clearing test

parent e0bfe2bd
......@@ -130,8 +130,19 @@ def test_clearing():
base_s = sum(base)
opt_s = sum(opt)
diff = opt_s - base_s
numerators = [b * diff for b in base]
fractions = [num // base_s for num in numerators]
res = [o - b - f for o, b, f in zip(opt, base, fractions)]
numerators = [(b * diff) + 1 for b in base]
fractions = []
rest = 0
for numerator in numerators:
div = numerator // base_s
mod = numerator % base_s
rest += mod
if rest > base_s:
fractions.append(div + 1)
rest -= base_s
else:
fractions.append(div)
res = [-(o - b - f) for o, b, f in zip(opt, base, fractions)]
comp = {k: sum([res[i] for i in v]) for k, v in mapping.items()}
assert json["values"] == comp
assert sum(res) == 0
Supports Markdown
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