-
Notifications
You must be signed in to change notification settings - Fork 887
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
Speeding up get_nn_info
in local_env.py
#3635
Conversation
`_get_image` and `_get_original_site` do not need to recompute site and index when `site` is a `PeriodicNeighbor` which has them as attributes.
Awesome. Thanks! I recently tried the minimum distance method for an amorphous structure 😅... |
@ftherrien thanks, much appreciated! the failing test here looks like maybe this doesn't handle translations correctly? shifting the TestCrystalNN.test_shifted_sites _______________________
self = <tests.analysis.test_local_env.TestCrystalNN testMethod=test_shifted_sites>
def test_shifted_sites(self):
cnn = CrystalNN()
sites = [[0.0, 0.2, 0.2], [0, 0, 0]]
struct = Structure([7, 0, 0, 0, 7, 0, 0, 0, 7], ["I"] * len(sites), sites)
bonded_struct = cnn.get_bonded_structure(struct)
sites_shifted = [[1.0, 0.2, 0.2], [0, 0, 0]]
struct_shifted = Structure([7, 0, 0, 0, 7, 0, 0, 0, 7], ["I"] * len(sites_shifted), sites_shifted)
bonded_struct_shifted = cnn.get_bonded_structure(struct_shifted)
> assert len(bonded_struct.get_connected_sites(0)) == len(bonded_struct_shifted.get_connected_sites(0))
E assert 1 == 2 |
…_sphere If the modulo is present the image returned by get_points_in_sphere does not point to the original site.
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.
thanks again @ftherrien!
Head branch was pushed to by a user without write access
@janosh the auto-merge was cancelled FYI |
I have merged now, @janosh , as you approved it already. |
Thanks y'all! |
_get_image
and_get_original_site
do not need to recompute site and index whensite
is aPeriodicNeighbor
which has them as attributes.When there are several sites, this makes a significant difference on speed for
get_nn_info
Alternative implementation would have been
try/except
andhasattr
.try/except
is much slower when most of the sites are notPeriodicNeighbor
.Summary
Major changes: