-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[2] Coord gen new #29
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm mostly missing docstrings
I still need to look at the tests
from polyply.src.generate_templates import (_atoms_in_node, find_atoms, | ||
_expand_inital_coords, | ||
compute_volume, map_from_CoG, | ||
extract_block, GenerateTemplates) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from ... import (
_atoms_in_node, ...
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also run and appease pylint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few more tiny nitpicks
del interaction.parameters[-1] | ||
for param in values: | ||
interaction.parameters.append(param) | ||
interaction.parameters[:] = new_parameters[:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires interaction.parameters to always be a list (and not e.g. a tuple). I'm not sure we can make that guarantee.
You can use interaction._replace
[1] to create a new interaction with the parameters replaced. You'd then still need to replace the interaction with the new one, but that is guaranteed to be a list.
[1] https://docs.python.org/2/library/collections.html#collections.somenamedtuple._replace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can. It is for sure a list as it comes out of the topology parser and the namedtuple clearly is setting the attribute as list. So it would be problematic when a programmer uses the function in their own code assuming it can be something else than a list. Although this can happen I think the chance is fairly small here. Let's put this up as an issue for enhancement, because using the replace doesn't propagate as easily all the way back. You need to replace and delete all old interaction lists and then all blocks in the force-field. I wish the named tuple had a replace function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tuples are immutable, so that makes sense.
What I meant is that Molecule.interactions
is guaranteed a dict[str, list]
. So you could do something like my_block.interactions[idx] = interaction._replace(parameters=new_parameters)
. But it's also fine to leave this until it breaks. Be sure to test this behaviour though!
comb_funcs = {1.0: lorentz_berthelot_rule, | ||
2.0: geometric_rule, | ||
3.0: lorentz_berthelot_rule} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't know why these are floats.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the gromacs default section allows the combination rule number to either be a float or an int. I don't want to type cast them as int in the parser on the one hand as this does not adhere to what is actually written in the file and on the other hand it saves some lines in the parser. I put a comment though.
…node-key, more tests
[2] Coord gen new
Hi,
This is part two of the coordinate generator namely the actual coord generator.
Enjoy!
Fabian