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 a from_ase_atoms() method to Structure #3812

Merged
merged 4 commits into from
May 7, 2024

Conversation

Andrew-S-Rosen
Copy link
Member

@Andrew-S-Rosen Andrew-S-Rosen commented May 7, 2024

Summary

Adds a .from_ase_atoms() method to Structure to complement the pre-existing .to_ase_atoms(). In reality, this is just a shorthand for the adapter, but it felt awkward to have one direction but not the other.

Checklist

  • Google format doc strings added. Check with ruff.
  • Type annotations included. Check with mypy.
  • Tests added for new features/fixes.
  • If applicable, new classes/functions/modules have duecredit @due.dcite decorators to reference relevant papers by DOI (example)

Tip: Install pre-commit hooks to auto-check types and linting before every commit:

pip install -U pre-commit
pre-commit install

Summary by CodeRabbit

  • New Features
    • Introduced a method for converting ase.Atoms to pymatgen Structure, enhancing interoperability between different scientific libraries.
  • Tests
    • Added new assertions to ensure reliability of the new conversion functionality.

Copy link

coderabbitai bot commented May 7, 2024

Walkthrough

The recent update involves enhancing the pymatgen Structure class with a new method for converting ase.Atoms to pymatgen structures. This improvement is complemented by an additional assertion in the test suite to validate the conversion process.

Changes

File Path Change Summary
pymatgen/core/structure.py Added from_ase_atoms method to Structure class for converting ase.Atoms to pymatgen Structure.
tests/core/test_structure.py Added assertion in test_to_ase_atoms to verify the new conversion method.

🐰✨
In the garden of code, where the data trees sway,
A new method hops in, oh what a day!
From ASE to pymatgen, a leap so bold,
Ensuring each atom is perfectly molded.
Cheers to the coders, with brains so bright,
For making our data dance just right! 🌟
🐇


Recent Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 6aa43fa and 803f315.
Files selected for processing (2)
  • pymatgen/core/structure.py (1 hunks)
  • tests/core/test_structure.py (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • pymatgen/core/structure.py
  • tests/core/test_structure.py

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 46b018d and f57d3be.
Files selected for processing (2)
  • pymatgen/core/structure.py (1 hunks)
  • tests/core/test_structure.py (1 hunks)

tests/core/test_structure.py Show resolved Hide resolved
pymatgen/core/structure.py Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between f57d3be and 6aa43fa.
Files selected for processing (1)
  • pymatgen/core/structure.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • pymatgen/core/structure.py

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.

nice one, thanks @Andrew-S-Rosen! 👍

@janosh janosh enabled auto-merge (squash) May 7, 2024 11:26
@janosh janosh added enhancement A new feature or improvement to an existing one ase Atomic simulation environment api Application programming interface labels May 7, 2024
@janosh janosh merged commit d9e9ef6 into materialsproject:master May 7, 2024
23 checks passed
@JaGeo
Copy link
Member

JaGeo commented May 7, 2024

Now I can simplify a lot of my lecture code. 😅
Thanks, @Andrew-S-Rosen !!

@Andrew-S-Rosen
Copy link
Member Author

@shyuep --- just chiming in with another vote to remove coderabbit. It's super annoying. If not though, I'll just keep sass talking back to it until it spontaneously decides not to review anymore.

@shyuep
Copy link
Member

shyuep commented May 7, 2024

@Andrew-S-Rosen Yes, it is just an experiment. But a question - are the proposed changes useful? I can understand the boiler is annoying and I can try to kill those off. Just wanted to know if there is any value or there is no value at all.

@Andrew-S-Rosen
Copy link
Member Author

Andrew-S-Rosen commented May 7, 2024

@Andrew-S-Rosen Yes, it is just an experiment. But a question - are the proposed changes useful? I can understand the boiler is annoying and I can try to kill those off. Just wanted to know if there is any value or there is no value at all.

@shyuep: In general, not really. I'm sure sometimes the proposed changes are useful, but the signal:noise ratio (both in terms of the chattiness and usefulness of the suggestions) is likely too low for contributors to get much value from it in my opinion. The only redeeming feature, in my view, is the edit of the original summary.

@shyuep
Copy link
Member

shyuep commented May 7, 2024

@Andrew-S-Rosen I don't really care for the summary. Ok, I will disable it.

One thing - I am not sure I want a from_ase_atoms. I would prefer a simple Structure.from_object. this will support ASE atoms for now, but I am sure there are a lot of different formats we can convert a structure from.

@Andrew-S-Rosen
Copy link
Member Author

@Andrew-S-Rosen I don't really care for the summary. Ok, I will disable it.

Much appreciated!

One thing - I am not sure I want a from_ase_atoms. I would prefer a simple Structure.from_object. this will support ASE atoms for now, but I am sure there are a lot of different formats we can convert a structure from.

This is a very good point. For instance, a Phonopy object might be relevant. In any case, I am fine with changes in this regard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Application programming interface ase Atomic simulation environment 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

4 participants