Always transplant a stub for transplanted methods#2427
Conversation
|
I will move the transplant of the stub in the metaclass to keep all the logic together. |
Codecov Report
@@ Coverage Diff @@
## develop #2427 +/- ##
===========================================
- Coverage 93.05% 93.05% -0.01%
===========================================
Files 186 186
Lines 24611 24651 +40
Branches 3188 3194 +6
===========================================
+ Hits 22902 22938 +36
- Misses 1661 1665 +4
Partials 48 48
Continue to review full report at Codecov.
|
Topology attributes can transplant methods in other classes (mostly the groups). This transplant, however only happens when a given attribute is attached to a topology. This causes issues including missing documentation for the transplanted methods and inonsitent error messages. This commit transplants a dummy method fo all transplants. This happens independently from the unverse creation, so the stubs can appear in the documentation. The stubs carry the docstring of their counterpart methods, and raise a NoDataError when called.
This reverts commit 2b45dc8.
Add funcsigs as a dependancy.
This avoids issues in sphinx about duplicate references in the stubs docstrings.
64853db to
db52364
Compare
|
Hello @jbarnoud! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2020-10-20 08:27:05 UTC |
|
I think this is ready for review. Maybe @lilyminium would have opinions about it. |
lilyminium
left a comment
There was a problem hiding this comment.
This looks great, thank you @jbarnoud! However, if it's not too much work to bring the Python 2 funcsigs back in, it would be great to backport this PR to master so the transplanted methods are documented in the 1.0.x docs too -- the methods do exist in that version as well.
Fix spelling and typos Co-authored-by: Lily Wang <31115101+lilyminium@users.noreply.github.com>
…lysis into feature/more-transplant
This reverts commit 5eb6250.
This will help with backport.
Help with backport.
|
@lilyminium I added back funcsign and got rid of an f-string to help with backport. The patch should work on python 2.7, but I did not try as the rest of develop doesn't. The uncovered code is the import of funcsign as it would only run on python 2. |
|
Thank you @jbarnoud for this nice solution! |
|
Thank you @jbarnoud – makes me happy that this is working. We can remove the funcsig stuff again – but it makes it easier to backport because we can cherry pick. |
backport of stub transplants of AtomGroup (PR #2427)
- Fixes MDAnalysis#1845 - Adds dummy method with documentation of original method - Dummy method gets replaced by actual method on instantiation

Fixes #1845
Methods and properties defined by topology attributes and transplanted in various core classes (groups and
Universe) do not appear in the documentation. Several solutions have been proposed to solve this problem:Here, instead, I systematically transplant a dummy method in the core class for each method that is to be transplanted. The dummy method mimics the name, signature, and documentation of the original method, but always raises a
NoDataError. The dummy methods (stubs) are picked up by sphinx and appear in the documentation. Also, the transplant methods from topology attributes that are not present in a given universe do not raise a confusingAttributeErrorany more, instead, they raise aNoDataErrorthat specify which attribute is missing.Compared to #2418, this method does not produce the cool looking tables and does not automatically tell that an attribute is required in the doc. It also has the same issue with reference duplicates (see #2176 (comment)). However, it does not require any manual operation.
The problem with the references is about one citation only, though.
Compared to #2424, it keeps all the benefit of the transplant as described in #601.
PR Checklist