move sorting stuff
This commit is contained in:
parent
06ff6449c3
commit
a039be4581
1 changed files with 0 additions and 35 deletions
|
|
@ -1,5 +1,3 @@
|
||||||
# %%
|
|
||||||
|
|
||||||
from typing import NamedTuple
|
from typing import NamedTuple
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -34,36 +32,3 @@ def sort_by_rules(in_list: list, rules: list[Rule]) -> bool:
|
||||||
return True
|
return True
|
||||||
print("failed")
|
print("failed")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
in_list = ["a", "b", "c", "d", "e", "f", "g"]
|
|
||||||
rules = [ # X depends on Y
|
|
||||||
Rule("a", "e"),
|
|
||||||
Rule("b", "e"),
|
|
||||||
Rule("b", "f"),
|
|
||||||
Rule("c", "e"),
|
|
||||||
Rule("d", "e"),
|
|
||||||
Rule("f", "e"),
|
|
||||||
]
|
|
||||||
|
|
||||||
print("before", in_list)
|
|
||||||
sort_by_rules(in_list, rules)
|
|
||||||
print("before", in_list)
|
|
||||||
|
|
||||||
|
|
||||||
def test_uniqueness(in_list: list):
|
|
||||||
assert len(set(in_list)) == len(in_list)
|
|
||||||
|
|
||||||
|
|
||||||
def test_rules(in_list, rules):
|
|
||||||
rule_satisfied: list[bool] = []
|
|
||||||
for rule in rules:
|
|
||||||
if is_rule_satisfied(in_list, rule):
|
|
||||||
rule_satisfied.append(True)
|
|
||||||
else:
|
|
||||||
rule_satisfied.append(False)
|
|
||||||
assert all(rule_satisfied)
|
|
||||||
|
|
||||||
|
|
||||||
test_uniqueness(in_list)
|
|
||||||
test_rules(in_list, rules)
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue