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

Improve k point labelling when there are discontinuities in the path #51

Merged
merged 3 commits into from
Aug 29, 2024

Conversation

zhubonan
Copy link
Contributor

@zhubonan zhubonan commented Aug 26, 2024

Combine the labels of points when there is a discontinuity. Such points are labelled by the A|B sytax.

Example:

figure

This fixes issue #49 where the flat bands are caused using the apparent distance between two k-point where the path was discontinuous.

Summary by CodeRabbit

  • New Features

    • Updated version to 0.3.7, indicating minor improvements and bug fixes.
    • Introduced a new parameter in the k-point distance calculations to control the visibility of discontinuities.
    • Added a new method for generating combined k-point labels, enhancing k-point representation.
  • Bug Fixes

    • Improved robustness in retrieving k-point labels.
  • Documentation

    • Added citation for L. Zhang et al.'s study to the README and documentation, enhancing user resources.

Combine kpoint labels when plotting the unfolded effective band
structure.
Copy link

coderabbitai bot commented Aug 26, 2024

Walkthrough

The changes involve updating the version number from 0.3.6 to 0.3.7 in the easyunfold/__init__.py file. In easyunfold/plotting.py, the method _add_kpoint_labels now retrieves k-point labels using a new method, get_combined_kpoint_labels(). Additionally, easyunfold/unfold.py introduces a new parameter in get_kpoint_distances to manage discontinuities and adds a new method for combined k-point labeling. Citation entries for a relevant paper are also added to the README.md and docs/index.md.

Changes

Files Change Summary
easyunfold/init.py Updated version number from 0.3.6 to 0.3.7.
easyunfold/plotting.py Modified _add_kpoint_labels to use self.unfold.get_combined_kpoint_labels() instead of self.unfold.kpoint_labels.
easyunfold/unfold.py Added hide_discontinuities parameter to get_kpoint_distances and introduced a new method get_combined_kpoint_labels.
README.md, docs/index.md Added citation for L. Zhang et al. Study of native point defects in Al0.5Ga0.5N by first principles calculations.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Unfold
    participant Plotting

    User->>Unfold: Call get_kpoint_distances(hide_discontinuities=True)
    Unfold->>Unfold: Check for discontinuities
    Unfold->>Unfold: Calculate distances
    Unfold-->>User: Return distances

    User->>Plotting: Call _add_kpoint_labels()
    Plotting->>Unfold: Call get_combined_kpoint_labels()
    Unfold-->>Plotting: Return combined kpoint labels
    Plotting-->>User: Add labels to kpoints
Loading

Poem

🐇 In the meadow where the bunnies play,
A new version hops in, hip-hip-hooray!
Kpoints now dance, labels in a line,
With distances clear, everything's fine.
So let's celebrate, with a joyful cheer,
For changes made, we hold so dear! 🌼


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.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

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

@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 016d0af and 08fbe21.

Files selected for processing (3)
  • easyunfold/init.py (1 hunks)
  • easyunfold/plotting.py (1 hunks)
  • easyunfold/unfold.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • easyunfold/init.py
Additional comments not posted (3)
easyunfold/plotting.py (1)

375-375: Verify the function usage in the codebase.

The method now retrieves k-point labels using self.unfold.get_combined_kpoint_labels(). Ensure that all function calls to _add_kpoint_labels are correctly updated to reflect this change.

Run the following script to verify the function usage:

Verification successful

Function Usage Verified

The function _add_kpoint_labels is consistently used across the codebase with the updated implementation. The calls to this function are correctly aligned with the changes made to retrieve k-point labels using self.unfold.get_combined_kpoint_labels().

  • All occurrences of _add_kpoint_labels in easyunfold/plotting.py reflect the new implementation.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `_add_kpoint_labels` match the new implementation.

# Test: Search for the function usage. Expect: Only occurrences of the new implementation.
rg --type python -A 5 $'_add_kpoint_labels'

Length of output: 73


Script:

#!/bin/bash
# Description: Verify all function calls to `_add_kpoint_labels` match the new implementation.

# Test: Search for the function usage. Expect: Only occurrences of the new implementation.
rg -A 5 '_add_kpoint_labels'

Length of output: 1328

easyunfold/unfold.py (2)

618-645: Verify the logic for handling discontinuities.

The function introduces a new parameter hide_discontinuities to handle discontinuities in the kpoint path. Ensure that the logic correctly identifies and adjusts distances for discontinuities.

  • Verify that the logic correctly identifies adjacent kpoint labels and adjusts distances accordingly.
  • Ensure that the function is tested with various kpoint paths to confirm the correctness of the discontinuity handling.

648-659: Verify the logic for combining labels.

The function combines adjacent kpoint labels into a single entry when they are directly connected. Ensure that the logic correctly identifies and combines adjacent labels.

  • Verify that the logic correctly identifies adjacent kpoint labels and combines them into a single entry.
  • Ensure that the function is tested with various kpoint labels to confirm the correctness of the label combination.

Copy link

codecov bot commented Aug 26, 2024

Codecov Report

Attention: Patch coverage is 84.21053% with 3 lines in your changes missing coverage. Please review.

Project coverage is 87.32%. Comparing base (016d0af) to head (467afdf).

Files Patch % Lines
easyunfold/unfold.py 82.35% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #51      +/-   ##
==========================================
- Coverage   87.37%   87.32%   -0.05%     
==========================================
  Files          10       10              
  Lines        2028     2044      +16     
==========================================
+ Hits         1772     1785      +13     
- Misses        256      259       +3     

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

@kavanase
Copy link
Member

Looks good to me @zhubonan! Thanks for dealing with this.
This updates the labelling for the projected plots too yeah? (From looking at the code changes I think it should)

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 08fbe21 and 467afdf.

Files selected for processing (2)
  • README.md (1 hunks)
  • docs/index.md (1 hunks)
Files skipped from review due to trivial changes (2)
  • README.md
  • docs/index.md

@zhubonan zhubonan merged commit 2579ac5 into main Aug 29, 2024
12 of 14 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