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

Fix parse_species to handle non-integer oxidation states #170

Merged
merged 6 commits into from
Sep 18, 2024
Merged

Conversation

AntObi
Copy link
Collaborator

@AntObi AntObi commented Sep 18, 2024

Pull Request Template

Description

  • Enable parse_species to handle non-integer oxidation states
  • Add blacken-docs to pre-commit

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

  • Added test for parsing non-integer oxidation states

Test Configuration:

  • Python version: 3.10
  • Operating System: macOS

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

    • Integrated blacken-docs for improved documentation formatting.
    • Enhanced species parsing to support decimal values for oxidation states.
  • Bug Fixes

    • Updated version number to indicate minor improvements.
  • Documentation

    • Improved formatting and readability in several documentation files, including README.md, contributing.md, and tutorial files.
  • Tests

    • Expanded test coverage for species parsing to include additional cases with decimal values.

Copy link

coderabbitai bot commented Sep 18, 2024

Walkthrough

The changes in this pull request include updates to multiple files, primarily focusing on formatting improvements, code style adjustments, and enhancements to testing and functionality. Notably, a new pre-commit configuration for the blacken-docs tool was added to ensure consistent documentation formatting. Additionally, the version number in setup.py was incremented, and various adjustments were made to code snippets across documentation files to enhance readability. The parsing functionality for species strings was also improved to accommodate decimal values.

Changes

Files Change Summary
.pre-commit-config.yaml Added support for blacken-docs tool with repository URL and version specification.
README.md, docs/tutorials.md, docs/embeddings/element.md, src/elementembeddings/data/element_representations/README.md Formatting improvements and code style adjustments for better readability and consistency, including consistent quotation marks and improved line breaks.
contributing.md Minor formatting adjustments, including a change to the header style.
setup.py Updated version number from "0.6" to "0.6.1".
src/elementembeddings/tests/test_utils.py Enhanced test coverage for parse_species function by adding new test cases for decimal values.
src/elementembeddings/utils/species.py Modified _parse_species_old function to allow parsing of floating-point oxidation states, changing return type from int to float.
src/elementembeddings/plotter.py Minor formatting change in the dimension_plotter function, no functional change.

Poem

In the garden of code, we hop with delight,
Formatting and tests, all shining so bright.
With blacken-docs now in our nest,
Our documentation's style is surely the best!
From species to plots, we’ve tidied the way,
Hopping along, let’s code and play! 🐇✨


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c6b93a7 and cb93b20.

Files selected for processing (10)
  • .pre-commit-config.yaml (1 hunks)
  • README.md (3 hunks)
  • contributing.md (2 hunks)
  • docs/embeddings/element.md (1 hunks)
  • docs/tutorials.md (3 hunks)
  • setup.py (1 hunks)
  • src/elementembeddings/data/element_representations/README.md (1 hunks)
  • src/elementembeddings/plotter.py (1 hunks)
  • src/elementembeddings/tests/test_utils.py (1 hunks)
  • src/elementembeddings/utils/species.py (1 hunks)
Files skipped from review due to trivial changes (7)
  • README.md
  • contributing.md
  • docs/embeddings/element.md
  • docs/tutorials.md
  • setup.py
  • src/elementembeddings/data/element_representations/README.md
  • src/elementembeddings/plotter.py
Additional comments not posted (5)
.pre-commit-config.yaml (1)

56-59: LGTM! The addition of the blacken-docs pre-commit hook aligns with the PR objectives.

The changes introduce a new pre-commit hook for the blacken-docs tool, which will help ensure consistent formatting of documentation files. The configuration specifies the correct repository URL and version (1.18.0) for the tool.

This addition will contribute to maintaining a uniform style across the project's documentation and improve overall readability.

src/elementembeddings/utils/species.py (1)

37-38: Excellent enhancement to handle non-integer oxidation states!

The updated regular expression and the conversion of ox_state to a float enable the function to parse and handle decimal values for oxidation states. This improvement aligns perfectly with the PR objective and extends the functionality of the parse_species function.

The changes are backward compatible, ensuring that integer oxidation states are still parsed correctly. The updated return type annotation accurately reflects the modification.

Great work on addressing this issue and enhancing the function's capabilities!

src/elementembeddings/tests/test_utils.py (3)

60-60: LGTM!

The assertion correctly tests the parse_species function's ability to handle a species string with a decimal quantity and a positive charge. The expected output matches the intended behavior described in the PR summary.


61-61: LGTM!

The assertion correctly tests the parse_species function's ability to handle a species string with a decimal quantity and a negative charge. The expected output matches the intended behavior described in the PR summary.


62-62: LGTM!

The assertion correctly tests the parse_species function's ability to handle a species string with a decimal quantity (more than 2 decimal places) and a positive charge. The expected output matches the intended behavior described in the PR summary.

It's great to see that the test case covers an additional scenario not explicitly mentioned in the PR summary, which is a good practice to ensure the robustness of the implementation.


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>, 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 generate interesting stats about this repository and render them as a table.
    -- @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 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

codecov bot commented Sep 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.95%. Comparing base (ae3fa47) to head (cb93b20).
Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #170      +/-   ##
==========================================
+ Coverage   90.85%   90.95%   +0.09%     
==========================================
  Files          12       12              
  Lines        1291     1294       +3     
==========================================
+ Hits         1173     1177       +4     
+ Misses        118      117       -1     

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

@AntObi AntObi merged commit 6c8bd34 into main Sep 18, 2024
15 checks passed
@AntObi AntObi deleted the 0.6.1_updates branch September 18, 2024 12:41
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