diff --git a/rmgpy/reaction.py b/rmgpy/reaction.py index b4a808790e..b5cc88395f 100644 --- a/rmgpy/reaction.py +++ b/rmgpy/reaction.py @@ -1529,16 +1529,22 @@ def same(object1, object2, _check_identical=check_identical, _only_check_label=o else: return object1.is_isomorphic(object2, generate_initial_map=_generate_initial_map, strict=_strict, save_order=_save_order) - - if len(list1) == len(list2) == 1: + maximum_length = 10 + len_list1 = len(list1) + if len_list1 != len(list2): + return False + if len_list1 == 0: + # List is empty + raise NotImplementedError("Can't check isomorphism of lists with {0} species/molecules".format(len_list1)) + elif len_list1 == 1: if same(list1[0], list2[0]): return True - elif len(list1) == len(list2) == 2: + elif len_list1 == 2: if same(list1[0], list2[0]) and same(list1[1], list2[1]): return True elif same(list1[0], list2[1]) and same(list1[1], list2[0]): return True - elif len(list1) == len(list2) == 3: + elif len_list1 == 3: if same(list1[0], list2[0]): if same(list1[1], list2[1]): if same(list1[2], list2[2]): @@ -1560,7 +1566,26 @@ def same(object1, object2, _check_identical=check_identical, _only_check_label=o elif same(list1[1], list2[1]): if same(list1[2], list2[0]): return True - elif len(list1) == len(list2): - raise NotImplementedError("Can't check isomorphism of lists with {0} species/molecules".format(len(list1))) - # nothing found + elif len_list1 <= maximum_length: + # Copy list to prevent changes to original input + l1=list1[:] + l2=list2[:] + x=0 + while x