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 cmap option to doper plots #285

Merged
merged 4 commits into from
Jul 10, 2024
Merged

Conversation

AntObi
Copy link
Collaborator

@AntObi AntObi commented Jul 10, 2024

Pull Request Template

Description

  • Doper().plot_dopants has a cmap argument to let users choose the colour of the heatmaps

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Test Configuration:

  • Python version: 3.10
  • Operating System: Windows 11

Reviewers

N/A

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Summary by CodeRabbit

  • New Features

    • Enhanced dopant suggestion functionality with more detailed categorisation by type and charge.
    • Customisable colormap for periodic table heatmap visualisation.
  • Improvements

    • get_dopants method now returns results in a nested dictionary format.
    • plot_dopants method supports a cmap parameter to choose colormap.

Copy link
Contributor

coderabbitai bot commented Jul 10, 2024

Warning

Rate limit exceeded

@AntObi has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 7 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 9c81d5e and 55dfa8c.

Walkthrough

The Doper class's get_dopants method now returns a nested dictionary categorising dopant suggestions by type and charge. Additionally, the plot_dopants method includes a new cmap parameter for customising the colormap in heatmap visualisations. These changes enhance data organisation and visual customisation capabilities in dopant prediction and visualisation.

Changes

File Change Summary
smact/dopant_prediction/doper.py - get_dopants method: Modified to return a nested dictionary categorised by type and charge.
- plot_dopants method: Added cmap parameter for colormap customisation in periodic table heatmap visualisation.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Doper
    participant get_dopants
    participant plot_dopants

    User->>Doper: call get_dopants(get_selectivity, group_by_charge)
    Doper->>get_dopants: retrieve dopants
    get_dopants-->>Doper: return nested dict by type and charge
    Doper-->>User: return dopants

    User->>Doper: call plot_dopants(cmap)
    Doper->>plot_dopants: generate heatmap with cmap
    plot_dopants-->>Doper: return visualisation
    Doper-->>User: return heatmap
Loading

Poem

> In the world of dopant delight,
> New structures now shine bright,
> With nested types and charges clear,
> Visuals with colours that endear,
> A rabbit's whimsy in the code,
> Enhancing pathways science showed. 🌟

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

codecov bot commented Jul 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.65%. Comparing base (cbf7515) to head (55dfa8c).
Report is 103 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #285   +/-   ##
========================================
  Coverage    74.65%   74.65%           
========================================
  Files           24       24           
  Lines         2099     2099           
========================================
  Hits          1567     1567           
  Misses         532      532           

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

Copy link
Contributor

@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

Outside diff range, codebase verification and nitpick comments (3)
smact/dopant_prediction/doper.py (3)

163-167: Document the new parameters.

The new parameters get_selectivity and group_by_charge need to be documented in the method's docstring.

+        Args:
+            num_dopants (int): The number of suggestions to return for n- and p-type dopants.
+            get_selectivity (bool): Whether to calculate the selectivity of the dopants.
+            group_by_charge (bool): Whether to group the dopants by charge.

168-170: Document the return value.

The return value format needs to be documented in the method's docstring.

+        Returns:
+            dict: Dopant suggestions, given as a dictionary with keys
+                  "n_type_cation", "p_type_cation", "n_type_anion", "p_type_anion".

379-379: Add parameter to docstring.

The new cmap parameter should be included in the docstring.

+        Args:
+            cmap (str): The colormap to use for the heatmap.
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 5d75a82 and 6dd042e.

Files selected for processing (1)
  • smact/dopant_prediction/doper.py (3 hunks)
Additional comments not posted (1)
smact/dopant_prediction/doper.py (1)

405-405: LGTM!

The addition of the cmap parameter looks good and enhances the functionality.

Copy link
Contributor

@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

Outside diff range, codebase verification and nitpick comments (1)
smact/dopant_prediction/doper.py (1)

Ensure proper documentation of new parameters.

The cmap parameter in the plot_dopants method is not documented in the docstring. Please update the docstring to include a description of this new parameter.

  • File: smact/dopant_prediction/doper.py
  • Line: 373-379
Analysis chain

Line range hint 376-384:
Ensure proper documentation of new parameters.

The plot_dopants method has a new parameter cmap. Ensure this parameter is well-documented in the docstring.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the documentation of the new `cmap` parameter in the `plot_dopants` method.

# Test: Search for the `cmap` parameter in the docstring. Expect: Parameter is documented.
rg --type python -A 5 $'def plot_dopants' | grep 'cmap'

Length of output: 85


Script:

#!/bin/bash
# Description: Verify the documentation of the new `cmap` parameter in the `plot_dopants` method.

# Test: Search for the `cmap` parameter in the docstring. Expect: Parameter is documented.
rg --lang py -A 5 $'def plot_dopants' | grep 'cmap'

Length of output: 459


Script:

#!/bin/bash
# Description: Verify the documentation of the new `cmap` parameter in the `plot_dopants` method.

# Test: Search for the `cmap` parameter in the docstring. Expect: Parameter is documented.
rg --type py -A 5 $'def plot_dopants' | grep 'cmap'

Length of output: 134

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6dd042e and 9c81d5e.

Files selected for processing (1)
  • smact/dopant_prediction/doper.py (3 hunks)
Additional comments not posted (3)
smact/dopant_prediction/doper.py (3)

Line range hint 167-183:
Ensure proper documentation of new parameters.

The get_dopants method has new parameters get_selectivity and group_by_charge. Ensure these parameters are well-documented in the docstring.

Verification successful

Verification successful: The new parameters get_selectivity and group_by_charge are properly documented in the docstring of the get_dopants method.

  • get_selectivity (bool): Whether to calculate the selectivity of the dopants.
  • group_by_charge (bool): Whether to group the dopants by charge.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the documentation of new parameters in the `get_dopants` method.

# Test: Search for the new parameters in the docstring. Expect: Parameters are documented.
rg --type python -A 5 $'def get_dopants' | grep -E 'get_selectivity|group_by_charge'

Length of output: 116


Script:

#!/bin/bash
# Description: Verify the documentation of new parameters in the `get_dopants` method.

# Test: Search for the new parameters in the docstring. Expect: Parameters are documented.
rg --type py -A 5 $'def get_dopants' | grep -E 'get_selectivity|group_by_charge'

Length of output: 193


Script:

#!/bin/bash
# Description: Extract and display the docstring for the `get_dopants` method to verify the documentation of new parameters.

# Extract the `get_dopants` method along with its docstring.
rg --type py -A 50 $'def get_dopants' smact/dopant_prediction/doper.py | grep -E '"""|def get_dopants|get_selectivity|group_by_charge'

Length of output: 412


Line range hint 402-406:
LGTM! Ensure custom colormap functionality is tested.

The code changes are approved. Ensure that the custom colormap functionality is tested.


174-247: Ensure consistency in return data format.

The method returns a nested dictionary structure. Verify that the new parameters do not impact the consistency of the returned data.

@AntObi AntObi merged commit 36025e6 into WMD-group:develop Jul 10, 2024
16 checks passed
@AntObi AntObi deleted the doper_fixes branch July 10, 2024 13:28
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.

1 participant