-
Notifications
You must be signed in to change notification settings - Fork 663
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
modified guess_atom_element for more accurate guess #4168
Conversation
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.
Hello there first time contributor! Welcome to the MDAnalysis community! We ask that all contributors abide by our Code of Conduct and that first time contributors introduce themselves on the developer mailing list so we can get to know you. You can learn more about participating here. Please also add yourself to package/AUTHORS
as part of this PR.
Linter Bot Results:Hi @pillose! Thanks for making this PR. We linted your code and found the following: Some issues were found with the formatting of your code.
Please have a look at the Please note: The |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## develop #4168 +/- ##
===========================================
+ Coverage 93.40% 93.41% +0.01%
===========================================
Files 169 183 +14
Lines 22202 23309 +1107
Branches 4064 4064
===========================================
+ Hits 20738 21775 +1037
- Misses 948 1018 +70
Partials 516 516
☔ View full report in Codecov by Sentry. |
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.
Hi @pillose! Thanks for the contribution!
Would you be able to add a test of the new behaviour? If you need help getting started with the test suite, feel free to ping me. You will also need to add an entry to package/CHANGELOG
.
Also as you are a new contributor (welcome!) please add yourself to package/AUTHORS
and also introduce yourself on the developer mailing list or discord.
@pillose this PR has been opened for a little while, are you still interested in contributing this code? |
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.
Looks good, two little comments. Did you end up introducing yourself on mailing list or discord :) ?
package/CHANGELOG
Outdated
@@ -19,6 +19,7 @@ The rules for this file: | |||
|
|||
Fixes | |||
* Fix Boltzmann typo in `units.py` (PR #4214, Issue #4213) | |||
* Fix Atom type guessing error (PR #4168, Issue #4167) |
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.
Order this newest first.
@@ -204,7 +204,12 @@ def guess_atom_element(atomname): | |||
except KeyError: | |||
# strip symbols and numbers | |||
no_symbols = re.sub(SYMBOLS, '', atomname) | |||
name = re.sub(NUMBERS, '', no_symbols).upper() | |||
no_numbers = re.split(NUMBERS, no_symbols) |
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.
Add some comments as to why this is now in here.
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.
@pillose - We are changing the license under which future contributions are released. Could you please confirm that you agree to releasing this code under the terms of the LGPLv2.1 and that your contribution also adheres to the developer certificate of origion?
1ce5387
to
66a2b21
Compare
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.
Thanks @pillose. Please see #4168 (review), thanks.
Co-authored-by: Rocco Meli <[email protected]>
Co-authored-by: Rocco Meli <[email protected]>
Co-authored-by: Rocco Meli <[email protected]>
package/AUTHORS
Outdated
@@ -220,6 +220,7 @@ Chronological list of authors | |||
- Mohit Kumar | |||
- Shubham Kumar | |||
- Zaheer Timol | |||
- GeongiMoon |
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.
Needs a space, I am assuming?
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.
If not let me know, other than that looks good.
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.
I missed a space... Thank you!
@@ -104,6 +104,9 @@ def test_guess_atom_element_1H(self): | |||
('zn', 'ZN'), | |||
('Ca2+', 'CA'), | |||
('CA', 'C'), | |||
('N0A', 'N'), |
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.
One more nit sorry could you test Na+ -> Na?
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.
I just added two tests for Na+ and Cu2+
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.
The one question from me.
no_numbers = re.split(NUMBERS, no_symbols) | ||
no_numbers = list(filter(None, no_numbers)) #remove '' | ||
# if no_numbers is not empty, use the first element of no_numbers | ||
name = list(filter(None, no_numbers))[0].upper() if no_numbers else '' |
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.
Apologies if I'm missing something obvious, but do you need to apply filter again here? You've already removed the ''
entries and you shouldn't have any None
entries ?
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.
Sorry, I think I made a mistake while modifying the code...
remove unnecessary code
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.
Thanks, sorry for this taking so long. lgtm!
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.
LGTM also thanks @pillose
Cycling CI |
Fixes #4167
Changes made in this Pull Request:
Suppose the function
guess_atom_element()
receives 'N0A' as an argumentWith previous code,
name = 'NA' # interpreted as sodium
Which substitute '0' to ''
With new code,
name = ['N', 'A'][0] #== 'N"
PR Checklist
📚 Documentation preview 📚: https://mdanalysis--4168.org.readthedocs.build/en/4168/