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
[DOC] Improve docstring rendering for typed experimental surface module #4049
Conversation
#: Labels array concatenated across both hemispheres | ||
labels_data_: np.ndarray | ||
#: Unique label values | ||
labels_: np.ndarray | ||
#: Label names if any, otherwise unique label values | ||
label_names_: np.ndarray |
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.
The pro is that the documentation is closer to where the attributes are declared in the code but this would mean rewriting a lot of doc, no?
Mesh and data for both hemispheres. | ||
|
||
y : None | ||
y | ||
This parameter is unused. It is solely included for scikit-learn | ||
compatibility. | ||
|
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.
Signal for each element. | ||
shape: (img data shape, total number of vertices) | ||
:return: Signal for each element with shape | ||
(img data shape, total number of vertices). | ||
""" |
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.
.. automodule:: nilearn.experimental.surface | ||
:no-members: | ||
:no-inherited-members: |
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.
this is actually needed to correctly reference the module and wasn't causing the :noindex: error in #4017
👋 @ymzayek Thanks for creating a PR! Until this PR is ready for review, you can include the [WIP] tag in its title, or leave it as a github draft. Please make sure it is compliant with our contributing guidelines. In particular, be sure it checks the boxes listed below.
For new features:
For bug fixes:
We will review it as quick as possible, feel free to ping us with questions if needed. |
Codecov Report
@@ Coverage Diff @@
## main #4049 +/- ##
==========================================
- Coverage 91.59% 91.51% -0.09%
==========================================
Files 143 143
Lines 16079 16079
Branches 3340 3340
==========================================
- Hits 14728 14715 -13
- Misses 804 819 +15
+ Partials 547 545 -2
Flags with carried forward coverage won't be shown. Click here to find out more. see 5 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
FWIW I did try Napoleon with the napoleon typehints extension but ran into a bunch of issues. While it has some nice features and can better standardize our docstrings, it seem to be incompatible with our current docstrings as they are so will either require some work to update those in the whole codebase or some more intense configs and workarounds. In contrast, the configs in this PR do not affect the docstrings of untyped code. And at least the decisions/issues resolved in this PR also seem to apply to and be compatible with Napoleon so someone can still switch to it later if desired |
Thanks for looking into this @ymzayek !! Some options would make the docstring writing much easier. Given this is related to type hints, should we maybe add this to the agenda for the next dev meeting? This may also help solve how to handle the PR and issues related to where to put "defaults" in the doc string. |
@Remi-Gau yes definitely, I've put it on the agenda under issues/PRs What I'm struggling with is trying to merge both approaches, i.e. having numpydoc style docstring in the codebase but substituting types (and defaults) automatically without doubling the parameters. The problem with the use of |
1a1a607
to
de6d168
Compare
Update: Now this PR deals with only points 1 and 2 of #4018. |
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, thx.
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 looking into all this @ymzayek
…le (nilearn#4049) * Correct linking * Fix note
* remove leading underscore from non private functions * rm underscores in datasets * rm underscores in decoding * update script * rename module * rm more leading underscore from decoding mass_univariate datasets * rename module * move functions * add doc string * rename functions * rename function * Update doc/changes/0.10.1.rst * flake8 * fix * Update nilearn/signal.py Co-authored-by: Yasmin <63292494+ymzayek@users.noreply.github.com> * typo (#4091) * [MAINT] update DOI and add RRID (#4032) * update DOI * update which DOI is used and add RRID * [DOC] mention checking badges during release (#4085) * [MAINT] Fix Zenodo DOI badge (#4093) * pre-commit hooks auto-update (#4097) Co-authored-by: Remi-Gau <Remi-Gau@users.noreply.github.com> * Remove extraneous hash symbols (#4096) * [DOC] Improve docstring rendering for typed experimental surface module (#4049) * Correct linking * Fix note * Add tagging (#4100) * [FIX] Disable extrapolation of out-of-bounds volumes (#4028) * expose CubicSpline extrapolate parameter (#4028) * [FIX] discard non-interpolated volumes and reset the sample_mask indexes * [REF] discard non-interpolated volumes and reset sample_mask in '_handle_scrubbed_volumes' * [FMT] black formatting * improve deprecation warning message * check that extrapolation warning is raised * add changelog and contribution entries * check consistency of modified sample_mask * assert modified sample_mask can be applied to signals and confounds * [REF] split signal extrapolation testing in 2 tests * [BOT] update AUTHORS.rst and doc/changes/names.rst (#4102) Co-authored-by: ymzayek <ymzayek@users.noreply.github.com> * [MAINT] Add listing utilities (#2991) * Add listing utilities * Add possibility to filter by modules * Add some tests * Fix PEP8 * Clarify ignored modules by default * Add section on Nilearn API in the user guide * Export at the end * [circle full] Add whats new * revert * more revert * lint * fix tests * lint * adapt tests to check number of public functions and classes * update doc strings * fix --------- Co-authored-by: Remi Gau <remi_gau@hotmail.com> * fix number of functions * adapt number of functions * update changelog --------- Co-authored-by: Yasmin <63292494+ymzayek@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Remi-Gau <Remi-Gau@users.noreply.github.com> Co-authored-by: Jordi Huguet <jhuguetn@gmail.com> Co-authored-by: ymzayek <ymzayek@users.noreply.github.com> Co-authored-by: Gensollen <nicolas.gensollen@gmail.com>
Changes proposed in this pull request:EDIT see #4049 (comment) below for what is covered in this PRnilearn/experimental/surface/_maskers.py
to test some options and after some decisions are made changes will be applied to the rest of this module. I'll add some comments and images to show differences of rendering.There are two main things to pay attention to. I tried just removing the type from the docstring and let it render in the signature so as to not repeat information. This leaves the parameter names and the description. The other way would be to change to way we write docstrings but it renders better. See docstring of
SurfaceLabelsMasker.fit_transform()
.