Skip to content

fix: DistanceConfFilter is optimized and the bug in BoxSkewnessConfFilter is fixed.#292

Merged
wanghan-iapcm merged 11 commits into
deepmodeling:masterfrom
Carrotkingdom:fix-filter
Apr 17, 2025
Merged

fix: DistanceConfFilter is optimized and the bug in BoxSkewnessConfFilter is fixed.#292
wanghan-iapcm merged 11 commits into
deepmodeling:masterfrom
Carrotkingdom:fix-filter

Conversation

@Carrotkingdom
Copy link
Copy Markdown

@Carrotkingdom Carrotkingdom commented Apr 15, 2025

The DistanceConfFilter is optimized and the bug in BoxSkewnessConfFilter is fixed.

Summary by CodeRabbit

  • Bug Fixes

    • Improved accuracy of hydrogen distance checks by updating the safe distance value.
    • Enhanced structure validation by refining lattice length and skewness checks for better symmetry handling.
  • Refactor

    • Streamlined distance and lattice checks to operate directly on the original structure, improving efficiency and reliability.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2025

📝 Walkthrough

Walkthrough

This update modifies the internal logic of the DistanceConfFilter.check and BoxSkewnessConfFilter.check methods within the distance configuration filtering module. The safe distance for hydrogen is reduced. The method for checking lattice dimensions now directly analyzes the standardized cell of the original structure, calculating various lattice vector combinations and comparing them to twice the safe atomic distances. The supercell expansion step is removed. The box skewness check now uses absolute values for off-diagonal cell components. No changes are made to public method signatures or class declarations.

Changes

File(s) Change Summary
dpgen2/exploration/selector/distance_conf_filter.py Refactored DistanceConfFilter.check to use standardized cell and direct lattice vector calculations instead of supercell; reduced safe distance for hydrogen; updated BoxSkewnessConfFilter.check to use absolute values in skewness checks.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DistanceConfFilter
    participant Structure

    User->>DistanceConfFilter: check(structure)
    DistanceConfFilter->>Structure: get_standardized_cell()
    DistanceConfFilter->>Structure: get_atom_types()
    DistanceConfFilter->>DistanceConfFilter: compute lattice vectors (a1, a2, a3)
    DistanceConfFilter->>DistanceConfFilter: calculate vector norms and combinations
    DistanceConfFilter->>DistanceConfFilter: compare lattice lengths to 2x safe distances
    alt Any lattice too short
        DistanceConfFilter-->>User: return False
    else
        DistanceConfFilter->>Structure: compute pairwise atomic distances
        DistanceConfFilter-->>User: return True/False
    end
Loading

Possibly related PRs

  • deepmodeling/dpgen2#250: Introduced the DistanceConfFilter class and its check method, which are the focus of the logic refinements in this PR.

Suggested reviewers

  • wanghan-iapcm

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 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 11feb59 and def1351.

📒 Files selected for processing (1)
  • dpgen2/exploration/selector/distance_conf_filter.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • dpgen2/exploration/selector/distance_conf_filter.py

🪧 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.
    • 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 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 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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

Copy link
Copy Markdown

@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

🧹 Nitpick comments (3)
dpgen2/exploration/selector/distance_conf_filter.py (3)

172-198: Consider simplifying lattice vector combination logic.
This extensive manual enumeration of vector sums and differences can be prone to missed permutations or future mistakes. You could dynamically generate these vectors to reduce boilerplate and ensure consistency.


200-202: Improve clarity by using more descriptive variable names or comments.
Naming the lists “A” and “B” can obscure the intent. Adding docstrings or clarifying variable names (e.g. all_lattice_lengths and safe_distances) can enhance readability.


203-207: Use logging instead of print for consistent verbosity handling.
Replacing print with logging.warning or an appropriate level helps maintain consistency with the rest of the codebase and aligns with best practices.

-                    print(f"Lattice length {a:.3f} is less than safe distance {b:.3f} ")
+                    logging.warning(f"Lattice length {a:.3f} is less than safe distance {b:.3f}")
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 749c7be and 1b33060.

📒 Files selected for processing (1)
  • dpgen2/exploration/selector/distance_conf_filter.py (3 hunks)
🔇 Additional comments (3)
dpgen2/exploration/selector/distance_conf_filter.py (3)

24-24: Please confirm the newly reduced hydrogen safe distance.
The hydrogen safe distance has been drastically lowered. This might relax previous proximity checks considerably. Ensure that this change aligns with the underlying modeling assumptions and does not introduce unintended behavior.


212-212: Validate use of minimum image convention (mic=True).
Ensure that relying on the periodic boundary condition interpretation is correct for all use cases, notably when the configuration might not be strictly periodic.


303-305: Good fix using absolute values for off-diagonal components.
Applying np.abs ensures symmetrical handling of negative skew values, preventing false negatives in the box skewness check.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2025

Codecov Report

Attention: Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 84.32%. Comparing base (749c7be) to head (def1351).
Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
...pgen2/exploration/selector/distance_conf_filter.py 87.50% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #292      +/-   ##
==========================================
- Coverage   84.32%   84.32%   -0.01%     
==========================================
  Files         104      104              
  Lines        6030     6041      +11     
==========================================
+ Hits         5085     5094       +9     
- Misses        945      947       +2     

☔ 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.

@wanghan-iapcm wanghan-iapcm changed the title Modification of the distance_conf_filter.py in exploration/selector fix: DistanceConfFilter is optimized and the bug in BoxSkewnessConfFilter is fixed. Apr 17, 2025
@wanghan-iapcm wanghan-iapcm merged commit 62e1661 into deepmodeling:master Apr 17, 2025
9 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.

3 participants