Skip to content

Conversation

@link89
Copy link
Contributor

@link89 link89 commented May 17, 2024

Summary by CodeRabbit

  • Enhancements
    • Improved the method for obtaining virials in the system by checking multiple sources before calculation, ensuring more accurate data handling.
  • Chores
    • Added a new optional dependency to support documentation building.

@coderabbitai
Copy link

coderabbitai bot commented May 17, 2024

📝 Walkthrough
Walkthrough

Walkthrough

The from_labeled_system method in dpdata/plugins/ase.py was updated to first attempt retrieving virials from atoms.info['virial'] before falling back to computing them from the stress tensor. A docstring note was added about virial loading sources, and minor whitespace cleanup was done.

Changes

Files Change Summary
.../dpdata/plugins/ase.py Updated from_labeled_system to get virials from atoms.info['virial'] or stress tensor; added docstring note; removed extra blank line in to_labeled_system.
pyproject.toml Added m2r>=0.3.1 to docs optional dependencies.

Possibly related PRs

Suggested reviewers

  • njzjz

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aa01708 and d6906f6.

📒 Files selected for processing (2)
  • dpdata/plugins/ase.py (2 hunks)
  • pyproject.toml (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • dpdata/plugins/ase.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: pass
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

@codecov
Copy link

codecov bot commented May 17, 2024

Codecov Report

❌ Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.39%. Comparing base (b91c598) to head (457de06).
⚠️ Report is 36 commits behind head on devel.

Files with missing lines Patch % Lines
dpdata/plugins/ase.py 77.77% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            devel     #660   +/-   ##
=======================================
  Coverage   85.38%   85.39%           
=======================================
  Files          82       82           
  Lines        7549     7552    +3     
=======================================
+ Hits         6446     6449    +3     
  Misses       1103     1103           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq
Copy link

codspeed-hq bot commented May 17, 2024

CodSpeed Performance Report

Merging #660 will not alter performance

Comparing link89:support-ase-virial (457de06) with devel (b91c598)

Summary

✅ 2 untouched benchmarks

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

@link89 link89 force-pushed the support-ase-virial branch from dd2ae5f to 451bd0d Compare May 19, 2024 08:00
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: 3

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: 1

🧹 Nitpick comments (2)
dpdata/plugins/ase.py (2)

109-109: Add validation for virial data format.

Consider adding basic validation to ensure the virial data has the expected shape and format before using it, especially since it can come from user-provided sources.

                 virials = np.array([-atoms.get_volume() * stress])
+                # Ensure virial has the expected shape (3, 3)
+                if virials.shape != (1, 3, 3):
+                    virials = virials.reshape(1, 3, 3)

100-100: Remove unnecessary blank line.

Minor whitespace cleanup to maintain consistent formatting.

-        }
-
+        }
         # try to get virials from different sources
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 774fb7d and f22e553.

📒 Files selected for processing (1)
  • dpdata/plugins/ase.py (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
dpdata/plugins/ase.py (2)
dpdata/abacus/scf.py (1)
  • get_stress (227-232)
dpdata/qe/scf.py (1)
  • get_stress (121-130)
🔇 Additional comments (1)
dpdata/plugins/ase.py (1)

65-68: Update documentation to include the missing 'virials' key.

Based on past review comments, the implementation should support both 'virial' and 'virials' keys as a fallback strategy. However, the current documentation only mentions 'virial' from atoms.info, missing the 'virials' fallback.

-        Note that this method will try to load virial from the following sources:
-        - atoms.info['virial']
-        - converted from stress tensor
+        Note that this method will try to load virials from the following sources:
+        
+        - atoms.info['virial']
+        - atoms.info['virials']
+        - converted from stress tensor

Likely an incorrect or invalid review comment.

@link89
Copy link
Contributor Author

link89 commented Jul 16, 2025

Hi @njzjz Is there any chance to see this PR in the next release of dpdata?
According to this code snippet from ase.io: https://gitlab.com/ase/ase/-/blob/master/ase/io/extxyz.py?ref_type=heads#L49

UNPROCESSED_KEYS = {'uid'}

SPECIAL_3_3_KEYS = {'Lattice', 'virial', 'stress'}

# partition ase.calculators.calculator.all_properties into two lists:
#  'per-atom' and 'per-config'

ase does support reading virial from the virial key of extxyz file. I think dpdata should also follow this conversion to load viral from the virial key.

@njzjz
Copy link
Member

njzjz commented Jul 16, 2025

Please let all checks pass.

@link89 link89 force-pushed the support-ase-virial branch from aa01708 to d6906f6 Compare July 16, 2025 14:44
@link89
Copy link
Contributor Author

link89 commented Jul 16, 2025

Resolved. I think the code coverage is a false positive.

@njzjz njzjz merged commit 1a1bb57 into deepmodeling:devel Jul 16, 2025
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants