-
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
Add formalcharge attribute and read/write them from PDB #3755
Conversation
Hello @IAlibay! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2022-07-23 09:36:35 UTC |
|
||
outcharges = charges.astype(object) | ||
outcharges[outcharges == 0] = '' # empty strings for no charge case | ||
# using np.where is more efficient than looping in sparse cases |
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.
We're looking at ~ 4x speedup for sparse arrays (which this will always be)
Codecov Report
@@ Coverage Diff @@
## develop #3755 +/- ##
========================================
Coverage 94.30% 94.31%
========================================
Files 192 192
Lines 24708 24752 +44
Branches 3328 3338 +10
========================================
+ Hits 23302 23345 +43
- Misses 1358 1359 +1
Partials 48 48
Continue to review full report at Codecov.
|
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.
Does the selection work if there's a space between the sign and the value? Eg "formalcharge + 1"
That'll throw (edit: as I would expect it to) a SelectionError, interestingly slightly different types of errors for Ranges do work here (since that's what int selections default to), so technically |
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.
Looking good, just a few queries. :)
else: | ||
formalcharges[i] = 0 | ||
attrs.append( | ||
FormalCharges(np.array(formalcharges, dtype=np.int32))) |
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 above question about int
vs int32
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.
Switching to int
here since the topologyattr code will just re-type to this anyways unless dtype is set to None.
That being said, charges really shouldn't exceed the bounds of int8, so one wonders how wasteful this is... (can't remember if int32/int64 still has the weird behaviour of ending up faster than int8/int16 in some weird cases)
assert_equal(u.atoms.formalcharges, formal_charges) | ||
|
||
|
||
PDB_charges_nosign = """\ |
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.
Could possibly be a fixture but i guess its not recycled, up to you :)
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'm going to skip on that, the advantages here are limited, especially given we use declared PDB strings like this everywhere else 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.
Thanks for addressing comments @IAlibay looks good to roll. You can merge when ready.
oops I think I got my subtypes the wrong way around |
Fixes #3418
Changes made in this Pull Request:
formalcharge
attribute - note this isn't the pretties names, so I'm 100% open to suggestions for renaming this.PR Checklist