Skip to content
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

Add cache to StructureStorage.get_elements #568

Merged
merged 4 commits into from
Mar 18, 2022
Merged

Add cache to StructureStorage.get_elements #568

merged 4 commits into from
Mar 18, 2022

Conversation

pmrv
Copy link
Contributor

@pmrv pmrv commented Mar 17, 2022

This method got quite slow when used on storages with millions of atoms, so I put a cache in front of it. The method is still slow, but iterating over large storages is usable now.

An alternative would be to save only element indices in the storage and translate them to chemical symbols. np.unique should be much faster on integers, but I haven't checked that and thought it's not necessary so far.

pmrv added 3 commits March 11, 2022 14:58
For multi million element storages this functions is quite slow ~1s, so
cache it.  We cannot use standard lib caches since arrays are mutable,
instead invalidate the cache on each write access to the 'symbols'
array.
@pmrv pmrv added enhancement New feature or request integration Start the notebook integration tests for this PR format_black reformat the code using the black standard labels Mar 17, 2022
@coveralls
Copy link

coveralls commented Mar 17, 2022

Pull Request Test Coverage Report for Build 2003366645

  • 10 of 10 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 70.482%

Totals Coverage Status
Change from base Build 1997558989: 0.02%
Covered Lines: 11860
Relevant Lines: 16827

💛 - Coveralls

@pmrv pmrv merged commit c9794de into master Mar 18, 2022
@delete-merged-branch delete-merged-branch bot deleted the fastge branch March 18, 2022 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request format_black reformat the code using the black standard integration Start the notebook integration tests for this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants