-
Notifications
You must be signed in to change notification settings - Fork 21
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
VEC function integration into smact.properties with a test file to serve as an example for its use. #305
Conversation
Warning Rate limit exceeded@ryannduma has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 36 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. WalkthroughThe changes introduce two new scripts, Changes
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this 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
Outside diff range, codebase verification and nitpick comments (1)
VECexample.py (1)
1-11
: Enhance error handling and validation.The example script lacks error handling for file operations and validation for the input compound. Consider adding try-except blocks to handle potential exceptions from the
valence_electron_count
function, such asFileNotFoundError
andValueError
.try: vec = valence_electron_count(compound, valence_file) print(f"The Valence Electron Count (VEC) for {compound} is: {vec:.2f}") except FileNotFoundError: print(f"Error: The file {valence_file} was not found.") except ValueError as e: print(f"Error: {e}")
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
elements_valence_modified.csv
is excluded by!**/*.csv
Files selected for processing (2)
- VECexample.py (1 hunks)
- smact/properties.py (2 hunks)
Additional context used
Ruff
smact/properties.py
204-204: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling(B904)
Thank you for submitting this PR @ryannduma . A few things before I can accept this PR.
|
There was a problem hiding this 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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- VECexample.py (1 hunks)
- smact/properties.py (2 hunks)
- smact/tests/test_core.py (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- VECexample.py
Additional context used
Ruff
smact/properties.py
1-1:
csv
imported but unusedRemove unused import:
csv
(F401)
197-197: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling(B904)
Additional comments not posted (3)
smact/properties.py (2)
184-191
: Consider refactoringparse_formula
for reusability.The
parse_formula
function is useful for extracting elements and stoichiometries from chemical formulas. Consider refactoring it into a standalone utility function for broader use within the module.
193-197
: Consider refactoringget_element_valence
for reusability.The
get_element_valence
function is useful for retrieving valence data from CSV rows. Consider refactoring it into a standalone utility function for broader use within the module.Tools
Ruff
197-197: Within an
except
clause, raise exceptions withraise ... from err
orraise ... from None
to distinguish them from errors in exception handling(B904)
smact/tests/test_core.py (1)
94-98
: Test functiontest_valence_electron_count
is well-structured.The test function effectively validates the
valence_electron_count
function, covering both correct calculations and error handling for invalid inputs.
@@ -1,3 +1,6 @@ | |||
import csv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused import csv
.
The csv
module is imported but not used in the file. Removing it will clean up the code.
-import csv
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
import csv |
Tools
Ruff
1-1:
csv
imported but unusedRemove unused import:
csv
(F401)
Hey Anthony, I have resolved all conflicts and the code now passes the qa stage of the CI except its failing all the other tests of the CI, how can I resolve that? |
There was a problem hiding this 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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- examples/vec_example.py (1 hunks)
- smact/properties.py (2 hunks)
- smact/tests/test_core.py (2 hunks)
Files skipped from review due to trivial changes (1)
- examples/vec_example.py
Files skipped from review as they are similar to previous changes (1)
- smact/tests/test_core.py
Additional context used
Ruff
smact/properties.py
1-1:
csv
imported but unusedRemove unused import:
csv
(F401)
Additional comments not posted (1)
smact/properties.py (1)
1-1
: Remove unused importcsv
.The
csv
module is imported but not used in the file. Removing it will clean up the code.Apply this diff to remove the unused import:
-import csv
Likely invalid or redundant comment.
Tools
Ruff
1-1:
csv
imported but unusedRemove unused import:
csv
(F401)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments
properties.py
There was a problem hiding this 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
Outside diff range, codebase verification and nitpick comments (1)
.pre-commit-config.yaml (1)
7-7
: Ensure consistent formatting forisort
arguments.The formatting of the
args
for theisort
hook has been adjusted. Ensure that this change aligns with the project's style guidelines.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- .pre-commit-config.yaml (2 hunks)
- examples/Crystal_Space/1_reduction.ipynb (1 hunks)
- smact/properties.py (2 hunks)
- smact/tests/test_core.py (2 hunks)
Files skipped from review due to trivial changes (1)
- examples/Crystal_Space/1_reduction.ipynb
Files skipped from review as they are similar to previous changes (1)
- smact/tests/test_core.py
Additional context used
Ruff
smact/properties.py
1-1:
csv
imported but unusedRemove unused import:
csv
(F401)
Additional comments not posted (4)
.pre-commit-config.yaml (1)
19-23
: Update nbQA version and compatibility.The
nbQA
version has been updated to1.8.7
, and the Python compatibility fornbqa-pyupgrade
has been changed to--py39-plus
. Ensure that these changes are compatible with the project's requirements and do not introduce any issues.smact/properties.py (3)
1-1
: Remove unused importcsv
.The
csv
module is imported but not used in the file. Removing it will clean up the code.Tools
Ruff
1-1:
csv
imported but unusedRemove unused import:
csv
(F401)
165-219
: Consider refactoring helper functions for reusability.The
valence_electron_count
function is well-implemented with appropriate error handling. However, consider refactoring theparse_formula
andget_element_valence
helper functions into standalone utility functions for broader use within the module.
193-199
: Improve exception handling inget_element_valence
.Use
raise ... from None
to distinguish it from errors in exception handling.
invalid elements ie Lr0
There was a problem hiding this 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
Files selected for processing (1)
- smact/tests/test_core.py (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- smact/tests/test_core.py
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #305 +/- ##
===========================================
+ Coverage 75.47% 75.67% +0.19%
===========================================
Files 24 24
Lines 2361 2183 -178
===========================================
- Hits 1782 1652 -130
+ Misses 579 531 -48 ☔ View full report in Codecov by Sentry. |
Merged! |
Hey @AntObi , the code passed the tests after a bunch of minor tweaks here and there to the types of errors raised, I noticed the Lr0 element check passed as a ValueError when passed to the function instead of a TypeError as presumed so I edited that part of the test to match, and it passed, though I dont know if thats exactly right, same to the Xx which isnt a valid element but I guess when parsed over is accepted because of the following codeblock, which ofc down the line, is found to not have a Valence number and then returns a ValueError instead of a NameError - please let me know what your thoughts are on this and whether additional tweaks need to be made. Thank you and have a good evening
|
VEC function Pull Request
Description
Hey, I hope this PR finds you well, I have now completed the integration of the VEC function succintly into the smact.properties.py module and attached a relevant example of it's use. I would also like to indicate that the function takes two arguments - the compound in question and a valence file - allowing for the user to select any file say magpie, or any existing valence file that they would like to use, in this case the example uses the modified file you shared.
I would like to highlight that this is a New feature (non-breaking change which adds functionality)
How Has This Been Tested?
Test Configuration: VECexample.py
Reviewers
@AntObi - Admin and Maintainer
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes
Tests