Closed JoshuaSBrown closed 5 years ago
Ah good catch - I believe I've run into this issue too. Is it fixed by simply using OrderedDict
?
Well after taking a second look, the order of the dict does not appear the problem because it it reading the keywords from the lammps.input file in the order they appear and then plugging the keywords into the dict. This is a problem in this case if the boundary keyword appears before the dict keyword. Not quite sure yet what the best approach is to fixing this yet... any other suggestions.
Perhaps move all the error checking to after everything has been scanned/read in?
Perhaps move all the error checking to after everything has been scanned/read in?
That sounds like the correct solution.
As a little tidbit - since Python 3.6, dict
preserves insertion order.
No longer seems relevant here, but it may not be widely known.
And as of 3.7 it's part of the spec! 🎉
So I found a bug with the lammps parser it is a result of using a dictionary to store the parser arguments and then running it in the for loop. I will submit a patch but here is the initial documentation in case of future problems:
The error has been localized to the boundary and dimension parsers:
Here they appear in the correct order. However, the dictionary does not imply that when you cycle through them they will appear in the same order as you have instantiated the key value pairs. Seeing that the boundary parser depends on the dimensions already being initiated this lead to a crash if the dict decides it wants to rearrange the order, which in my case it has done.