Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions rmgpy/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand All @@ -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<len(l1):
found_y = False
for y in range(len(l2)):
if same(l1[x],l2[y]):
found_y = True
del l1[x]
x-=1
del l2[y]
break
if not(found_y):
return False
x+=1
return (len(l1)==0) and (len(l2)==0)
else:
# List is too long
raise NotImplementedError("Can't check isomorphism of lists with {0} species/molecules".format(len_list1))

return False