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 Structure.sublattices and class RandomStructureTransformation to standard_transformations.py #3057

Open
wants to merge 28 commits into
base: master
Choose a base branch
from

Conversation

exenGT
Copy link
Contributor

@exenGT exenGT commented Jun 10, 2023

Closes #3049.

@mkhorton
Copy link
Member

Thanks @exenGT, I added a question to the associated issue.

pymatgen/transformations/standard_transformations.py Outdated Show resolved Hide resolved
pymatgen/core/structure.py Outdated Show resolved Hide resolved
pymatgen/transformations/standard_transformations.py Outdated Show resolved Hide resolved
pymatgen/transformations/standard_transformations.py Outdated Show resolved Hide resolved
@exenGT
Copy link
Contributor Author

exenGT commented Jun 16, 2023

@janosh All your suggestions have been addressed in my latest commits.

@janosh janosh changed the title Adding property sublattices to pymatgen/core/structure.py; adding class RandomStructureTransformation to pymatgen/transformations/standard_transformations.py Add Structure.sublattices and class RandomStructureTransformation to standard_transformations.py Jun 16, 2023
Copy link
Member

@janosh janosh left a comment

Choose a reason for hiding this comment

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

@exenGT Looking good! Could you add a test in test_standard_transformations.py?

pymatgen/transformations/standard_transformations.py Outdated Show resolved Hide resolved
subl = structure.sublattices

# fill the sublattice sites with pure-element atoms
self.all_structures = []
Copy link
Member

Choose a reason for hiding this comment

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

is it necessary to store the structures on the transformation instance? might balloon mem usage if people create many of these RandomStructureTransformations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used this syntax because there is an is_one_to_many property in the class; should it be False by default? (I see it is True for other classes)

Copy link
Member

Choose a reason for hiding this comment

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

I think there's no connection between is_one_to_many (that part is good) and storing the transformed structures on the transformation instance?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you elaborate more on this? I feel I'm not totally understanding. For example, the apply_transformation method of OrderDisorderedTransformation returns a list of structures as well (self._all_structures). What is the issue with this approach?

Copy link
Member

Choose a reason for hiding this comment

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

Could you explain the need to store all structures for later? Why not just return them and let them be garbage collected if they go out of scope in the user's code? Currently they live as long as the Transformation instance which is not great given structures are notoriously mem hungry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. This feature is here simply because I'm copying what's been written for the other transformations. If you think it's not a good approach, then I can modify it in my code accordingly.

@janosh janosh added enhancement A new feature or improvement to an existing one needs testing PRs that are not ready to merge due to lacking tests labels Jun 16, 2023
@exenGT exenGT force-pushed the dev branch 5 times, most recently from 6d162f3 to 84f7832 Compare June 29, 2023 02:23
@codecov-commenter
Copy link

codecov-commenter commented Aug 16, 2023

Codecov Report

Patch coverage: 86.36% and project coverage change: -0.57% ⚠️

Comparison is base (5f369ec) 74.69% compared to head (b72f962) 74.12%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3057      +/-   ##
==========================================
- Coverage   74.69%   74.12%   -0.57%     
==========================================
  Files         230      230              
  Lines       69375    69419      +44     
  Branches    16154    16163       +9     
==========================================
- Hits        51818    51460     -358     
- Misses      14490    14923     +433     
+ Partials     3067     3036      -31     
Files Changed Coverage Δ
...matgen/transformations/standard_transformations.py 86.04% <83.78%> (-0.22%) ⬇️
pymatgen/core/structure.py 85.81% <100.00%> (+0.05%) ⬆️

... and 7 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@janosh janosh force-pushed the master branch 2 times, most recently from 3c23114 to 36e289c Compare December 19, 2023 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature or improvement to an existing one needs testing PRs that are not ready to merge due to lacking tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate random ordered structures from disordered structure
4 participants