Skip to content

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

Conversation

umesh-timalsina
Copy link
Member

adds get_association method to return a set of sites associated with an atomtype or
a set of bonds associated with a bond_type and so on.

adds get_association method to return a set of sites associated with an atomtype or
a set of bonds associated with a bond_type and so on.
@codecov
Copy link

codecov bot commented Mar 27, 2020

Codecov Report

Merging #378 into master will increase coverage by 0.02%.
The diff coverage is 96.29%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #378      +/-   ##
==========================================
+ Coverage   93.09%   93.12%   +0.02%     
==========================================
  Files          74       74              
  Lines        5084     5133      +49     
==========================================
+ Hits         4733     4780      +47     
- Misses        351      353       +2     
Impacted Files Coverage Δ
gmso/core/topology.py 92.68% <94.44%> (+0.10%) ⬆️
gmso/tests/test_topology.py 100.00% <100.00%> (ø)
gmso/utils/decorators.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0569863...8ea2d2d. Read the comment docs.

Copy link
Collaborator

@justinGilmer justinGilmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! I had one comment/request for an additional unit test, but other than that, LGTM!

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):
Copy link
Collaborator

Choose a reason for hiding this comment

The 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 len(get_associations(broken_water) is now 2.

Would be a good test to have. and this same example should work for angletype too.

Copy link
Collaborator

@rmatsum836 rmatsum836 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good! Thanks @umesh-timalsina, I just had two minor comments. We also discussed Monday changing get_associations to get_type_associations. I personally like this change but would like to get the opinions of @mosdef-hub/mosdef-contributors as well.

self._connection_types = {}
self._bond_types = {}
self._bond_types_associations = {}
Copy link
Collaborator

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.

Copy link
Member Author

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.

Copy link
Collaborator

@rmatsum836 rmatsum836 Apr 16, 2020

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.

@umesh-timalsina
Copy link
Member Author

Probably better to close it and open it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add number of connections assocaited with a connection_type in a topology
3 participants