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

Return self from all SiteCollection/Structure/Molecule in-place modification methods #3623

Merged
merged 9 commits into from Feb 14, 2024

Conversation

janosh
Copy link
Member

@janosh janosh commented Feb 14, 2024

Non-breaking change but makes for a more functional API since modification methods can now be chained.

E.g. frequent use case of loading a file from disk/memory and directly applying an in-place modification previously required 2 lines:

struct = Structure.from_file("path/to/file")
struct.add_oxidation_state_by_guess()

but can now be shortened to

struct = Structure.from_file("path/to/file").add_oxidation_state_by_guess()

@janosh janosh added enhancement A new feature or improvement to an existing one api Application programming interface core Pymatgen core labels Feb 14, 2024
@janosh janosh merged commit b11c063 into master Feb 14, 2024
11 of 12 checks passed
@janosh janosh deleted the struct-mol-modify-methods-ret-self branch February 14, 2024 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Application programming interface core Pymatgen core enhancement A new feature or improvement to an existing one
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant