Fix/sort names (#177)

* cosmetic fix in sort_names

* bug fix, more tests
This commit is contained in:
Justus Kuhlmann 2023-05-16 19:28:32 +02:00 committed by GitHub
parent 15d07de87f
commit 5155effbbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 12 deletions

View file

@ -6,4 +6,27 @@ def test_sort_names():
presorted_list = ['sfqcd_r1_id5', 'sfqcd_r2_id5', 'sfqcd_r2_id9', 'sfqcd_r7_id5', 'sfqcd_r10_id4', 'sfqcd_r10_id5']
sorted_list = pe.input.utils.sort_names(my_list)
assert (all([sorted_list[i] == presorted_list[i] for i in range(len(sorted_list))]))
assert (all([sorted_list[i] == presorted_list[i] for i in range(len(sorted_list))]))
def test_sort_names_only_ids():
my_list = ['sfcf_T_id2', 'sfcf_T_id1', 'sfcf_T_id0', 'sfcf_T_id6', 'sfcf_T_id5']
presorted_list = ['sfcf_T_id0', 'sfcf_T_id1', 'sfcf_T_id2', 'sfcf_T_id5', 'sfcf_T_id6']
sorted_list = pe.input.utils.sort_names(my_list)
assert (all([sorted_list[i] == presorted_list[i] for i in range(len(sorted_list))]))
def test_sort_names_only_reps():
my_list = ['sfcf_T_r2', 'sfcf_T_r1', 'sfcf_T_r0', 'sfcf_T_r6', 'sfcf_T_r5']
presorted_list = ['sfcf_T_r0', 'sfcf_T_r1', 'sfcf_T_r2', 'sfcf_T_r5', 'sfcf_T_r6']
sorted_list = pe.input.utils.sort_names(my_list)
assert (all([sorted_list[i] == presorted_list[i] for i in range(len(sorted_list))]))
def test_sort_names_fallback():
my_list = ['xql2', 'xql1', 'xql0', 'xql6', 'xql5']
presorted_list = ['xql0', 'xql1', 'xql2', 'xql5', 'xql6']
sorted_list = pe.input.utils.sort_names(my_list)
assert (all([sorted_list[i] == presorted_list[i] for i in range(len(sorted_list))]))