-
Notifications
You must be signed in to change notification settings - Fork 35
Add get_associations method to topology class (Closes #375) #378
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -419,6 +419,26 @@ def test_topology_atom_type_changes(self): | |
assert top.sites[10].atom_type.name == 'atom_type_changed' | ||
assert top.is_typed() | ||
|
||
def test_get_associations_atom_types(self): | ||
top = Topology() | ||
atom_type = AtomType(name='test_atomtype') | ||
for i in range(10): | ||
top.add_site(Site(name=f'site{i+1}', atom_type=atom_type), update_types=True) | ||
assert len(top.get_associations(atom_type)) == 10 | ||
|
||
def test_get_association_atom_types_after_changes(self, typed_ar_system): | ||
typed_ar_system.atom_types[0].name = 'Typed Ar System' | ||
assert typed_ar_system.get_associations(typed_ar_system.atom_types[0]) == set(typed_ar_system.sites) | ||
|
||
def test_get_association_bond_types(self, typed_water_system): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure if this fits here, but what if we had a system with bonds (water would be an example: H-O-H) In this case, bondtype should have a set that contains all 3 sites. If we then removed a bond between one of the H and O (H O-H) We expect that the Would be a good test to have. and this same example should work for angletype too. |
||
bond_type = typed_water_system.bond_types[0] | ||
assert len(typed_water_system.get_associations(bond_type)) == 4 | ||
|
||
def test_get_association_bond_types_after_changes(self, typed_water_system): | ||
bond_type = typed_water_system.bond_types[0] | ||
bond_type.name = 'Typed water system' | ||
assert type(typed_water_system.get_associations(bond_type)) == set | ||
|
||
def test_topology_get_index(self): | ||
top = Topology() | ||
conn_members = [Site(), Site(), Site(), Site()] | ||
|
@@ -487,3 +507,4 @@ def test_topology_get_index_angle_type_after_change(self, typed_methylnitroanili | |
prev_idx = typed_methylnitroaniline.get_index(angle_type_to_test) | ||
typed_methylnitroaniline.angles[0].connection_type.name = 'changed name' | ||
assert typed_methylnitroaniline.get_index(angle_type_to_test) != prev_idx | ||
|
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.
Really small nit but types is plural in
_atom_types_associations
and_bond_types_associations
but is singular in_angle_type_associations
. I think I would actually prefer these all be singular type (_atom_type_associations
,_bond_type_associations
, etc.) because it reads a little bit better to me, but it's worth getting opinions from the rest of @mosdef-hub/mosdef-contributors.Either way the naming should be consistent.
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.
The reason for naming it with
_****_types_associations
was because it is a dictionary of all the connection types in the topology, which will contain a set. I have no preference one way or other.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.
Got it, I'm fine with
_****_types_associations
then.