Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Implementation of Parallelization to
MDAnalysis.analysis.contacts
#4820base: develop
Are you sure you want to change the base?
Implementation of Parallelization to
MDAnalysis.analysis.contacts
#4820Changes from 11 commits
828a6ff
da9d33d
a9d37a1
9c52851
11f696a
b25abb5
96332e3
19229f5
b1d6284
de345f4
9f0a02e
02f3ae5
00b92b7
7c2affc
e1ee672
626178f
4cf88aa
21231de
4ce62d1
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
?
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.
@RMeli I tried running it with the suggestion locally and I get
AttributeError: Can't get local object 'Contacts.__init__.<locals>.<lambda>'
It is somehow due to the parallelization having problems with lamba, it also does not like this
it leads to the same error, so yes I would agree that the function is quite general, so moving
def get_box()
to be a function in theContacts
class would be fine? since that wouldworks with the tests
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 wouldn't put
get_box()
elsewhere because it's really a bit clunky and not really that useful except that it's needed here (or do we have other places where we need it??). I'd keep it as local and non-public as possible. Writing it as a lambda would be the nicest way but if that does not work (... good to know and a bit sad ...) then I'd make it a static private class methodwhich you can then use for the partial.
Add a comment to
self._get_box = functools.partial(self._get_box_func, pbc=self.pbc)
why all of this is necessary.(I assume that following will run into the same issue as lambdas:
as it's also local, right?)
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 @talagayev for the explanation, I didn't know a lambda would not work in this case. I think defining a function instead of a lambda will in our in the same issue, as you suspect @orbeckst, but haven't tried. If we don't want to move the function elsewhere, I agree it should be private and not exposed by the module.
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, tried it right now locally, leads sadly to the
Can't get local object 'Contacts.__init__.<locals>.get_box'
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.
but yes making it more local static method is a more sophisticated way then it is currently, will adjust it then :)
as for it being used anywhere else, not really, it is only used here 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.
@orbeckst @RMeli I moved it now as you suggested and would re request the review, to see if it is correct now :)