Skip to content

Commit

Permalink
[DOC] use double backticks in rst files (#4010)
Browse files Browse the repository at this point in the history
* update config

* fix backticks

* fix backticks

* fix typo
  • Loading branch information
Remi-Gau committed Sep 26, 2023
1 parent 0d39ce2 commit b214dce
Show file tree
Hide file tree
Showing 28 changed files with 268 additions and 197 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ repos:
- id: pretty-format-toml
args: [--autofix, --indent, '4']

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: rst-backticks

- repo: https://github.com/pyCQA/flake8
rev: 6.1.0
hooks:
Expand Down
28 changes: 14 additions & 14 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -475,13 +475,13 @@ If you are not familiar with pytest,
have a look at this `introductory video <https://www.youtube.com/watch?v=mzlH8lp4ISA>`_
by one of the pytest core developer.

In general tests for a specific module (say `nilearn/image/image.py`)
are kept in a `tests` folder in a separate module
In general tests for a specific module (say ``nilearn/image/image.py``)
are kept in a ``tests`` folder in a separate module
with a name that matches the module being tested
(so in this case `nilearn/image/tests/test_image.py`).
(so in this case ``nilearn/image/tests/test_image.py``).

When you have added a test you can check that your changes worked
and didn't break anything by running `pytest nilearn`.
and didn't break anything by running ``pytest nilearn``.
To do quicker checks it's possible to run only a subset of tests:

.. code-block:: bash
Expand All @@ -497,19 +497,19 @@ you can use `pytest fixtures <https://docs.pytest.org/en/6.2.x/fixture.html>`_
to help you mock this data
(more information on pytest fixtures in `this video <https://www.youtube.com/watch?v=ScEQRKwUePI>`_).

Fixture are recognizable because they have a `@pytest.fixture` decorator.
Fixtures that are shared by many tests modules can be found in `nilearn/conftest.py`
Fixture are recognizable because they have a ``@pytest.fixture`` decorator.
Fixtures that are shared by many tests modules can be found in ``nilearn/conftest.py``
but some fixures specific to certain modules can also be kept in that testing module.

Before adding new fixtures, first check those that exist
in the test modules you are working in or in `nilearn/conftest.py`.
in the test modules you are working in or in ``nilearn/conftest.py``.

Seeding
^^^^^^^

Many tests must be seeded to avoid random failures.
When your test use random numbers,
you can seed a random number generator with `numpy.random.default_rng`
you can seed a random number generator with ``numpy.random.default_rng``
like in the following examples:

.. code-block:: python
Expand All @@ -521,7 +521,7 @@ like in the following examples:
# the rest of the test
You can also use the `rng` fixture.
You can also use the ``rng`` fixture.

.. code-block:: python
Expand Down Expand Up @@ -588,7 +588,7 @@ or:
conda create -n nilearn
conda activate nilearn
3. install the forked version of `nilearn`
3. install the forked version of ``nilearn``

.. admonition:: Recommendation

Expand Down Expand Up @@ -637,7 +637,7 @@ The installed version will also reflect any changes you make to your code.
pytest nilearn
5. (optional) install `pre-commit <https://pre-commit.com/#usage>`__ hooks
5. (optional) install `pre-commit <https://pre-commit.com/#usage>`_ hooks
to run the linter and other checks before each commit:

.. code-block:: bash
Expand All @@ -648,7 +648,7 @@ The installed version will also reflect any changes you make to your code.
Contributing
------------

Here are the key steps you need to go through to contribute code to `nilearn`:
Here are the key steps you need to go through to contribute code to ``nilearn``:

1. open or join an already existing issue explaining what you want to work on

Expand Down Expand Up @@ -697,7 +697,7 @@ Here are the key steps you need to go through to contribute code to `nilearn`:
git push
7. in github, open a pull request from your online fork to the main repo
(most likely from `your_fork:your_branch` to `nilearn:main`).
(most likely from ``your_fork:your_branch`` to ``nilearn:main``).

8. check that all continuous integration tests pass

Expand All @@ -719,7 +719,7 @@ If you wish to build documentation:
2. Then go to ``nilearn/examples`` or ``nilearn/doc`` and make needed changes
using `reStructuredText files <https://www.sphinx-doc.org/en/2.0/usage/restructuredtext/basics.html>`_

3. You can now go to `nilearn/doc` and build the examples locally:
3. You can now go to ``nilearn/doc`` and build the examples locally:

.. code-block:: bash
Expand Down
14 changes: 7 additions & 7 deletions doc/building_blocks/manual_pipeline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ example, we can download the data from the
from nilearn import datasets
dataset = datasets.fetch_haxby()
`dataset.func` contains filenames referring to dataset files on the disk:
``dataset.func`` contains filenames referring to dataset files on the disk:

.. code-block:: default
Expand Down Expand Up @@ -68,7 +68,7 @@ to the subjects from the brain activation.

These conditions are presented as string into a CSV file. The `pandas
<http://pandas.pydata.org/>`__ function
`read_csv` is very useful to load this kind of data.
``read_csv`` is very useful to load this kind of data.

.. literalinclude:: ../../examples/00_tutorials/plot_decoding_tutorial.py
:start-after: # We use pandas to load them in an array.
Expand Down Expand Up @@ -156,16 +156,16 @@ order to learn simple parameters from it, such as its shape:
fmri_masked = masker.fit_transform(fmri_filename)
Note that you can call `nifti_masker.transform(dataset.func[1])` on new
Note that you can call ``nifti_masker.transform(dataset.func[1])`` on new
data to mask it in a similar way as the data that was used during the
fit.

Automatically computing a mask
...............................

If your dataset does not provide a mask, the Nifti masker will compute
one for you in the `fit` step. The generated mask can be accessed via the
`mask_img_` attribute.
one for you in the ``fit`` step. The generated mask can be accessed via the
``mask_img_`` attribute.

Detailed information on automatic mask computation can be found in:
:ref:`extracting_data`.
Expand All @@ -174,7 +174,7 @@ Applying a scikit-learn machine learning method
================================================

Now that we have a 2D array, we can apply any estimator from the
scikit-learn, using its `fit`, `predict` or `transform` methods.
scikit-learn, using its ``fit``, ``predict`` or ``transform`` methods.

Here, we use scikit-learn Support Vector Classification to learn how to
predict the category of picture seen by the subject:
Expand All @@ -198,7 +198,7 @@ Unmasking (inverse_transform)
=============================

Unmasking data is as easy as masking it! This can be done by using
method `inverse_transform` on your processed data. As you may want to
method ``inverse_transform`` on your processed data. As you may want to
unmask several kinds of data (not only the data that you previously
masked but also the results of an algorithm), the masker is clever and
can take data of dimension 1D (resp. 2D) to convert it back to 3D
Expand Down
2 changes: 1 addition & 1 deletion doc/changes/0.10.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ NEW
Fixes
-----

- :bdg-danger:`Deprecation` Improve how :func:`~.glm.first_level.first_level_from_bids` handles fetching slice timing metadata and add additional input validation. In release ``0.12`` the default `slice_time_ref` will be `None` instead of `0` (:gh:`3605` by `Rémi Gau`_).
- :bdg-danger:`Deprecation` Improve how :func:`~.glm.first_level.first_level_from_bids` handles fetching slice timing metadata and add additional input validation. In release ``0.12`` the default ``slice_time_ref`` will be ``None`` instead of ``0`` (:gh:`3605` by `Rémi Gau`_).

- :bdg-dark:`Code` Fixes several bugs in :func:`~glm.first_level.first_level_from_bids`. Refactors :func:`~glm.first_level.first_level_from_bids` and ``nilearn._utils.data_gen.create_fake_bids_dataset``. (:gh:`3525` by `Rémi Gau`_).

Expand Down
16 changes: 8 additions & 8 deletions doc/changes/0.7.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ NEW
:class:`nilearn.decoding.DecoderRegressor` (for regression) implement a model
selection scheme that averages the best models within a cross validation loop.
The resulting average model is the one used as a classifier or a regressor.
These two objects also leverage the `NiftiMaskers` to provide a direct
These two objects also leverage the ``NiftiMaskers`` to provide a direct
interface with the Nifti files on disk.
- :bdg-success:`API` New FREM object
:class:`nilearn.decoding.FREMClassifier` (for classification) and
Expand All @@ -48,14 +48,14 @@ NEW
implicit spatial regularization) and aggregates a high number of estimators
trained on various splits of the training set. This returns a state-of-the-art
decoding pipeline at a low computational cost.
These two objects also leverage the `NiftiMaskers` to provide a direct
These two objects also leverage the ``NiftiMaskers`` to provide a direct
interface with the Nifti files on disk.
- :bdg-info:`Plotting` Plot events file
Use :func:`nilearn.plotting.plot_event` to visualize events file.
The function accepts the :term:`BIDS` events file read using `pandas`
The function accepts the :term:`BIDS` events file read using ``pandas``
utilities.
- :bdg-info:`Plotting` Plotting function :func:`nilearn.plotting.plot_roi` can now plot ROIs
in contours with `view_type` argument.
in contours with ``view_type`` argument.
- :bdg-info:`Plotting` New plotting function
:func:`nilearn.plotting.plot_carpet` generates a "carpet plot" (also known
as a "Power plot" or a "grayplot"), for visualizing global patterns in
Expand All @@ -70,21 +70,21 @@ NEW
- :bdg-info:`Plotting` New plotting function
:func:`nilearn.plotting.plot_surf_contours` plots the contours of regions of
interest on the surface, optionally overlaid on top of a statistical map.
- :bdg-info:`Plotting` The position annotation on the plot methods now implements the `decimals` option
- :bdg-info:`Plotting` The position annotation on the plot methods now implements the ``decimals`` option
to enable annotation of a slice coordinate position with the float.
- :bdg-primary:`Doc` New example in
:ref:`sphx_glr_auto_examples_02_decoding_plot_haxby_searchlight_surface.py`
to demo how to do cortical surface-based searchlight decoding with Nilearn.
- :bdg-success:`API` confounds or additional regressors for design matrix can be specified as
numpy arrays or pandas DataFrames interchangeably
- :bdg-success:`API` The decomposition estimators will now accept argument `per_component`
with `score` method to explain the variance for each component.
- :bdg-success:`API` The decomposition estimators will now accept argument ``per_component``
with ``score`` method to explain the variance for each component.


Fixes
-----

- :bdg-dark:`Code` :class:`nilearn.maskers.NiftiLabelsMasker` no longer ignores its `mask_img`
- :bdg-dark:`Code` :class:`nilearn.maskers.NiftiLabelsMasker` no longer ignores its ``mask_img``
- :bdg-dark:`Code` :func:`nilearn.masking.compute_brain_mask` has replaced
``nilearn.masking.compute_gray_matter_mask``. Features remained the same but
some corrections regarding its description were made in the docstring.
Expand Down
2 changes: 1 addition & 1 deletion doc/changes/0.8.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Fixes

- :bdg-dark:`Code` Fix detrending and temporal filtering order for confounders in function :func:`~signal.clean`, so that these operations are applied in the same order as for the signals, i.e., first detrending and then temporal filtering (see :gh:`2730`) (:gh:`2732` by `Javier Rasero`_).

- :bdg-success:`API` Fix number of attributes returned by the `nilearn.glm.first_level.FirstLevelModel._get_voxelwise_model_attribute` method in the :class:`~glm.first_level.FirstLevelModel`. It used to return only the first attribute, and now returns as many attributes as design matrices (:gh:`2792` by `Raphael Meudec`_).
- :bdg-success:`API` Fix number of attributes returned by the ``nilearn.glm.first_level.FirstLevelModel._get_voxelwise_model_attribute`` method in the :class:`~glm.first_level.FirstLevelModel`. It used to return only the first attribute, and now returns as many attributes as design matrices (:gh:`2792` by `Raphael Meudec`_).

- :bdg-info:`Plotting` Plotting functions that show a stack of slices from a 3D image (e.g. :func:`~plotting.plot_stat_map`) will now plot the slices in the user specified order, rather than automatically sorting into ascending order (see :gh:`1155`) (:gh:`2831` by `Evan Edmond`_).

Expand Down
6 changes: 3 additions & 3 deletions doc/changes/0.8.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Fixes

- :bdg-success:`API` Function :func:`~masking.compute_multi_brain_mask` has replaced ``nilearn.masking.compute_multi_grey_matter_mask``. A ``mask`` parameter has been added; it accepts three types of masks---i.e. ``whole-brain``, ``grey-matter``, and ``white-matter``---following the enhancements made in the function :func:`nilearn.masking.compute_brain_mask` in this release (:gh:`2738` by `Ana Luisa Pinho`_).

- :bdg-info:`Plotting` Fix colorbar of function :func:`~plotting.view_img` which was not visible for some combinations of `black_bg` and `bg_img` parameters (:gh:`2876` by `Nicolas Gensollen`_).
- :bdg-info:`Plotting` Fix colorbar of function :func:`~plotting.view_img` which was not visible for some combinations of ``black_bg`` and ``bg_img`` parameters (:gh:`2876` by `Nicolas Gensollen`_).

- :bdg-info:`Plotting` Fix missing title with function :func:`~plotting.plot_surf` and deriving functions (:gh:`2941` by `Nicolas Gensollen`_).

Expand All @@ -56,11 +56,11 @@ Enhancements

- :bdg-dark:`Code` Function :func:`~masking.compute_brain_mask` accepts now as input the whole-brain, 1mm-resolution, MNI152 T1 template instead of the averaged, whole-brain, 2mm-resolution MNI152 T1 template; it also accepts as input the grey-matter and white-matter ICBM152 1mm-resolution templates dated from 2009 (:gh:`2738` by `Ana Luisa Pinho`_).

- :bdg-secondary:`Maint` Common parts of docstrings across Nilearn can now be filled automatically using the decorator `nilearn._utils.fill_doc`. This can be applied to common function parameters or common lists of options for example. The standard parts are defined in a single location (`nilearn._utils.docs.py`) which makes them easier to maintain and update (:gh:`2875` by `Nicolas Gensollen`_).
- :bdg-secondary:`Maint` Common parts of docstrings across Nilearn can now be filled automatically using the decorator ``nilearn._utils.fill_doc``. This can be applied to common function parameters or common lists of options for example. The standard parts are defined in a single location (`nilearn._utils.docs.py`) which makes them easier to maintain and update (:gh:`2875` by `Nicolas Gensollen`_).

- :bdg-success:`API` The ``data_dir`` argument can now be either a :class:`pathlib.Path` or a :obj:`str`. This extension affects datasets and atlas fetchers (:gh:`2928` by `Raphael Meudec`_).

Changes
-------

- :bdg-secondary:`Maint` The version of the script `jquery.min.js` was bumped from ``3.3.1`` to ``3.6.0`` due to potential vulnerability issues with versions ``< 3.5.0`` (:gh:`2944` by `Nicolas Gensollen`_).
- :bdg-secondary:`Maint` The version of the script ``jquery.min.js`` was bumped from ``3.3.1`` to ``3.6.0`` due to potential vulnerability issues with versions ``< 3.5.0`` (:gh:`2944` by `Nicolas Gensollen`_).
2 changes: 1 addition & 1 deletion doc/changes/0.9.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Fixes

- :bdg-dark:`Code` Fix function :func:`~datasets.fetch_abide_pcp` which was returning empty phenotypes and ``func_preproc`` after release ``0.9.0`` due to supporting pandas dataframes in fetchers (:gh:`3174` by `Nicolas Gensollen`_).

- :bdg-dark:`Code` Fix function :func:`~datasets.fetch_atlas_harvard_oxford` and :func:`~datasets.fetch_atlas_juelich` which were returning the image in the `filename` attribute instead of the path to the image (:gh:`3179` by `Raphael Meudec`_).
- :bdg-dark:`Code` Fix function :func:`~datasets.fetch_atlas_harvard_oxford` and :func:`~datasets.fetch_atlas_juelich` which were returning the image in the ``filename`` attribute instead of the path to the image (:gh:`3179` by `Raphael Meudec`_).

- :bdg-dark:`Code` Fix function ``nilearn.image._apply_cluster_size_threshold``, which resulted in wrong clusters extraction when ``cluster_size`` was non-zero (:gh:`3201` by `Bertrand Thirion`_).

Expand Down

0 comments on commit b214dce

Please sign in to comment.