You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think we are misusing next() in this context (it works but it is not the proper way to do this and whenever errors occur the traceback is a bit difficult):
What are we doing here?
We are selecting an atom from a molecule based on a fragment atom id (stored in bond). This selection should result in exactly one atom. Then, we are using next() to extract this one atom from the list comprehension. This is problematic in two ways:
(1) What if the selection returns no atom? Throws StopIteration I think.
(2) What if the selection returns multiple atoms? Should never happen but we should add a check.
What do I suggest?
Remove next(). Store selection in a list and go through all cases with if-elif-else (0, 1, >1 atoms), raise proper errors for 0 and >1 atoms.
The text was updated successfully, but these errors were encountered:
I think we are misusing next() in this context (it works but it is not the proper way to do this and whenever errors occur the traceback is a bit difficult):
What are we doing here? We are selecting an atom from a molecule based on a fragment atom id (stored in bond). This selection should result in exactly one atom. Then, we are using next() to extract this one atom from the list comprehension. This is problematic in two ways: (1) What if the selection returns no atom? Throws StopIteration I think. (2) What if the selection returns multiple atoms? Should never happen but we should add a check.
What do I suggest? Remove next(). Store selection in a list and go through all cases with if-elif-else (0, 1, >1 atoms), raise proper errors for 0 and >1 atoms.
when I try to run
4_3_combinatorial_library_comparison_klifs notebook
the same error occured.
The strange thing is that I just simply run the original code without making any changes. What should I do?
many thanks,
I think we are misusing
next()
in this context (it works but it is not the proper way to do this and whenever errors occur the traceback is a bit difficult):KinFragLib/kinfraglib/utils.py
Lines 1297 to 1302 in 99e94c2
What are we doing here?
We are selecting an atom from a molecule based on a fragment atom id (stored in
bond
). This selection should result in exactly one atom. Then, we are usingnext()
to extract this one atom from the list comprehension. This is problematic in two ways:(1) What if the selection returns no atom? Throws
StopIteration
I think.(2) What if the selection returns multiple atoms? Should never happen but we should add a check.
What do I suggest?
Remove
next()
. Store selection in a list and go through all cases withif-elif-else
(0, 1, >1 atoms), raise proper errors for 0 and >1 atoms.The text was updated successfully, but these errors were encountered: