-
Notifications
You must be signed in to change notification settings - Fork 652
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
basic guesser features #3753
basic guesser features #3753
Conversation
Hello @aya9aladdin! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2022-09-12 19:40:16 UTC |
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 @aya9aladdin, this is a neat start! I only had time to skim but left a couple comments. The tests are failing because _GUESSERS can't be imported -- it's not in the top level __init__.py
yet.
package/MDAnalysis/core/universe.py
Outdated
@@ -1436,6 +1439,19 @@ def from_smiles(cls, smiles, sanitize=True, addHs=True, | |||
|
|||
return cls(mol, **kwargs) | |||
|
|||
def guess_topoloyAttribute(self, context, to_guess): |
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.
def guess_topoloyAttribute(self, context, to_guess): | |
def guess_TopologyAttr(self, context, to_guess): |
There's already a method called add_TopologyAttr
, and the class is called a TopologyAttr
. Going with the principal of least astonishment that advises a consistent API, could you please rename this method to something that users could easily guess (😛) themselves?
context = 'default' | ||
|
||
def __init__(self): | ||
self._guess = {'mass': self.guess_masses} |
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.
Hmm. Instead of this, would it be tidier to have a class-level _guess
dictionary like TopologyAttr.transplants
? I'm not sure it makes sense for instances of guesser classes to differ.
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'll check this and see how I could integrate the transplant idea
package/MDAnalysis/guesser/base.py
Outdated
.format(self.context, a)) | ||
return True | ||
|
||
def guessTopologyAttribute(self, to_guess): |
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.
In the absence of type hinting, could you please change the name of the to_guess
variables to be clearer? here it's one string, but in is_guessed
it's a list of strings -- that is quite confusing. Also, could you please name your methods with conventional snake_case and use TopologyAttr instead of TopologyAttribute?
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.
Do you plan to have an overall method for guessing all the attributes at once?
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.
Yes I'm planning to have a method for guessing all the attributes at once, this was just a test for guessing one attribute
package/MDAnalysis/guesser/base.py
Outdated
values = self._guess[to_guess]() | ||
return values | ||
|
||
def setAtoms(self, atoms): |
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 this method need to exist? Could __init__
just take atoms instead, like a Writer
?
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 don't remember why I did it this way tbh, so I'll remove it
@aya9aladdin I recommend that you push your changes often. Do not wait for the code to be finished. By pushing often, we get to see your progress, we get to comment on your latest version instead of a version that may already be obsolete, and we may catch issues earlier, reducing the amount of work you will have to redo. |
I was planning to push everything when I finish indeed. I don't know if I have to make a pull request at this unmatured level or not? |
You already have a pull request, no need to open another one. Instead, update this pull request by pushing your new commits. |
I have made some updates: 2- some attributes depend on other attributes to be guessed. if those parent attributes also need to be guessed, this can raise unnecessary errors if we attempted to guess the child attribute before the parent one. So, I added a rank dictionary to the guesser class which will rank each attribute based on its dependency on parent attributes to be guessed. For example , next update will have: |
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 had a partial look through, I hope the minor comments help.
I'm just more concerned with the logic than the documentation at the moment that's why it's not very accurate |
remove guessing types and masses from parsers
…lysis into guesser-basics
I updated some files as follows: What I would do next: |
- updated guess_TopologyAttrs docs - fixed some tests - capitalize atomtypes from elements in RDKitParser
@lilyminium @IAlibay I pushed last updates, let me know if any other updates is needed |
Thanks @aya9aladdin!! Will aim to get my review in by this weekend. |
I won't be able to re-review for a little while unfortunately, probably end of the week or next weekend. |
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 for the delay, I have two remaining questions, but happy to approve.
@lilyminium would it be ok if you took care of shepherding the remaining things?
""" | ||
def __init__(self, topology=None, *coordinates, all_coordinates=False, | ||
format=None, topology_format=None, transformations=None, | ||
guess_bonds=False, vdwradii=None, fudge_factor=0.55, | ||
lower_bound=0.1, in_memory=False, | ||
lower_bound=0.1, in_memory=False, context='default', | ||
to_guess=('types', 'masses'), force_guess=(), |
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.
to_guess=('types', 'masses'), force_guess=(), | |
to_guess=('types', 'masses'), force_guess=None, |
Could you confirm that keeping ()
instead of None
was intentional?
See: #3753
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.
@lilyminium feel free to turn this into an issue, we can fix this in post.
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.
yes it's intended to be that way indeed, for easier manuplation
@@ -303,8 +306,7 @@ def parse(self, **kwargs): | |||
if atomtypes: | |||
attrs.append(Atomtypes(np.array(atomtypes, dtype=object))) | |||
else: | |||
atomtypes = guessers.guess_types(names) | |||
attrs.append(Atomtypes(atomtypes, guessed=True)) | |||
atomtypes = np.char.upper(elements) |
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.
@aya9aladdin @lilyminium - this is assigned but nothing else is done with it afterwards it seems? I feel like I'm missing something, could you please just double check?
repinging @lilyminium - we should try to get this (and any subsequent fixes) into 2.8.0 |
Co-authored-by: Lily Wang <[email protected]>
Thanks, @aya9aladdin, everything looks good to go! Really excited to merge this. The only discussion point left is in which release. We have one coming up (2.8.0) that we could make as the feature freeze is tomorrow (Sunday). IMO this should definitely go in before 3.0, but it may be too fast for 2.8.0 as we wouldn't have a lot of testing before putting it in a published release. @MDAnalysis/coredevs do you have any opinions on if this PR should get merged into 2.8.0, or wait for a prospective 2.9? The deadline for making it into 2.8.0 is 8 hours from the time of this comment as that's the time I have before the feature freeze sets in (apologies for how fast that is). If there are no comments otherwise I will follow the default current plan as I understand it and merge this into Below are some pros/cons IMO for merging into 2.8: Pros:
Cons:
|
My take right now is that if we're hesitant on getting this in for 2.8 then let's wait on 2.9. |
Since there's been no discussion otherwise, I'm calling it -- this should get auto-merged into |
That is huge ! Congratulations @aya9aladdin ! I am extremely glad to see this project reach its conclusion 🚀 |
Dismissed old review due to being stale.
I am thrilled to have this merged!! thankful for all your revies and the experience.... looking forward to use the new functionality and contributing more to MDAnalysis! |
Congrats @aya9aladdin - it's been a long road but definitely a great addition to the library. |
Congratulations @aya9aladdin — awesome!! also big thank you to @lilyminium and @IAlibay for all your support! |
Hi @aya9aladdin - I emailed you about relicensing some of your historical contributions, please let me know if you didn't get the email. |
Fixes #
Changes made in this Pull Request:
PR Checklist