Skip to content

Commit cbd7690

Browse files
authored
Merge pull request #1200 from ZviBaratz/doc/docstrings
DOC: Standardize module-level docstrings format
2 parents 3f1c6f9 + 7903364 commit cbd7690

33 files changed

+29
-71
lines changed

Diff for: nibabel/affines.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
3-
"""Utility routines for working with points and affine transforms
4-
"""
3+
"""Utility routines for working with points and affine transforms"""
54
from functools import reduce
65

76
import numpy as np
@@ -100,7 +99,7 @@ def apply_affine(aff, pts, inplace=False):
10099

101100

102101
def to_matvec(transform):
103-
"""Split a transform into its matrix and vector components.
102+
"""Split a transform into its matrix and vector components
104103
105104
The transformation must be represented in homogeneous coordinates and is
106105
split into its rotation matrix and translation vector components.
@@ -312,8 +311,7 @@ def voxel_sizes(affine):
312311

313312

314313
def obliquity(affine):
315-
r"""
316-
Estimate the *obliquity* an affine's axes represent.
314+
r"""Estimate the *obliquity* an affine's axes represent
317315
318316
The term *obliquity* is defined here as the rotation of those axes with
319317
respect to the cardinal axes.

Diff for: nibabel/arraywriters.py

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def __init__(self, array, out_dtype=None)
2828
something else to make sense of conversions between float and int, or between
2929
larger ints and smaller.
3030
"""
31-
3231
import numpy as np
3332

3433
from .casting import (

Diff for: nibabel/brikhead.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
# copyright and license terms.
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
9-
"""
10-
Class for reading AFNI BRIK/HEAD datasets
9+
"""Class for reading AFNI BRIK/HEAD datasets
1110
1211
See https://afni.nimh.nih.gov/pub/dist/doc/program_help/README.attributes.html
1312
for information on what is required to have a valid BRIK/HEAD dataset.

Diff for: nibabel/data.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
3-
"""
4-
Utilities to find files from NIPY data packages
5-
"""
3+
"""Utilities to find files from NIPY data packages"""
64
import configparser
75
import glob
86
import os

Diff for: nibabel/deprecated.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""Module to help with deprecating objects and classes
2-
"""
1+
"""Module to help with deprecating objects and classes"""
32
from __future__ import annotations
43

54
import typing as ty

Diff for: nibabel/deprecator.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""Class for recording and reporting deprecations
2-
"""
1+
"""Class for recording and reporting deprecations"""
32
from __future__ import annotations
43

54
import functools

Diff for: nibabel/dft.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
99
# Copyright (C) 2011 Christian Haselgrove
10-
"""DICOM filesystem tools
11-
"""
10+
"""DICOM filesystem tools"""
1211

1312

1413
import contextlib

Diff for: nibabel/ecat.py

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
GPL and some of the header files are adapted from CTI files (called CTI code
4343
below). It's not clear what the licenses are for these files.
4444
"""
45-
4645
import warnings
4746
from numbers import Integral
4847

Diff for: nibabel/environment.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
3-
"""
4-
Settings from the system environment relevant to NIPY
5-
"""
6-
3+
"""Settings from the system environment relevant to NIPY"""
74
import os
85
from os.path import join as pjoin
96

Diff for: nibabel/eulerangles.py

-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
``y``, followed by rotation around ``x``, is known (confusingly) as
8383
"xyz", pitch-roll-yaw, Cardan angles, or Tait-Bryan angles.
8484
"""
85-
8685
import math
8786
from functools import reduce
8887

Diff for: nibabel/filebasedimages.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# copyright and license terms.
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
9-
"""Common interface for any image format--volume or surface, binary or xml."""
9+
"""Common interface for any image format--volume or surface, binary or xml"""
1010
from __future__ import annotations
1111

1212
import io

Diff for: nibabel/fileholders.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
99
"""Fileholder class"""
10-
1110
from copy import copy
1211

1312
from .openers import ImageOpener

Diff for: nibabel/filename_parser.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
99
"""Create filename pairs, triplets etc, with expected extensions"""
10-
1110
import os
1211
import pathlib
1312

Diff for: nibabel/fileslice.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""Utilities for getting array slices out of file-like objects
2-
"""
3-
1+
"""Utilities for getting array slices out of file-like objects"""
42
import operator
53
from functools import reduce
64
from mmap import mmap

Diff for: nibabel/fileutils.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
# copyright and license terms.
77
#
88
# ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
9-
"""Utilities for reading and writing to binary file formats
10-
"""
9+
"""Utilities for reading and writing to binary file formats"""
1110

1211

1312
def read_zt_byte_strings(fobj, n_strings=1, bufsize=1024):

Diff for: nibabel/imageclasses.py

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
99
"""Define supported image classes and names"""
10-
1110
from .analyze import AnalyzeImage
1211
from .brikhead import AFNIImage
1312
from .cifti2 import Cifti2Image

Diff for: nibabel/imageglobals.py

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
2424
Use ``logger.level = 1`` to see all messages.
2525
"""
26-
2726
import logging
2827

2928
error_level = 40

Diff for: nibabel/imagestats.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
# copyright and license terms.
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
9-
"""
10-
Functions for computing image statistics
11-
"""
12-
9+
"""Functions for computing image statistics"""
1310
import numpy as np
1411

1512
from nibabel.imageclasses import spatial_axes_first

Diff for: nibabel/loadsave.py

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
99
# module imports
1010
"""Utilities to load and save image objects"""
11-
1211
import os
1312

1413
import numpy as np

Diff for: nibabel/mriutils.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
# copyright and license terms.
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
9-
"""
10-
Utilities for calculations related to MRI
11-
"""
9+
"""Utilities for calculations related to MRI"""
1210

1311
__all__ = ['calculate_dwell_time']
1412

Diff for: nibabel/nifti2.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
1313
https://www.nitrc.org/forum/message.php?msg_id=3738
1414
"""
15-
1615
import numpy as np
1716

1817
from .analyze import AnalyzeHeader

Diff for: nibabel/onetime.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
Descriptor support for NIPY.
1+
"""Descriptor support for NIPY
32
43
Utilities to support special Python descriptors [1,2], in particular the use of
54
a useful pattern for properties we call 'one time properties'. These are

Diff for: nibabel/openers.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
# copyright and license terms.
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
9-
"""Context manager openers for various fileobject types
10-
"""
11-
9+
"""Context manager openers for various fileobject types"""
1210
import gzip
1311
import warnings
1412
from bz2 import BZ2File

Diff for: nibabel/orientations.py

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
99
"""Utilities for calculating and applying affine orientations"""
10-
11-
1210
import numpy as np
1311
import numpy.linalg as npl
1412

Diff for: nibabel/parrec.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
99
# Disable line length checking for PAR fragments in module docstring
1010
# flake8: noqa E501
11-
"""Read images in PAR/REC format.
11+
"""Read images in PAR/REC format
1212
1313
This is yet another MRI image format generated by Philips scanners. It is an
1414
ASCII header (PAR) plus a binary blob (REC).
@@ -121,7 +121,6 @@
121121
utility via the option "--strict-sort". The dimension info can be exported
122122
to a CSV file by adding the option "--volume-info".
123123
"""
124-
125124
import re
126125
import warnings
127126
from collections import OrderedDict

Diff for: nibabel/processing.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
# copyright and license terms.
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
9-
"""Image processing functions for:
9+
"""Image processing functions
1010
11-
* smoothing
12-
* resampling
13-
* converting sd to and from FWHM
11+
Image processing functions for:
1412
15-
Smoothing and resampling routines need scipy
16-
"""
13+
* smoothing
14+
* resampling
15+
* converting SD to and from FWHM
1716
17+
Smoothing and resampling routines need scipy.
18+
"""
1819
import numpy as np
1920
import numpy.linalg as npl
2021

Diff for: nibabel/quaternions.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
99
"""
10-
Functions to operate on, or return, quaternions.
10+
Functions to operate on, or return, quaternions
1111
1212
The module also includes functions for the closely related angle, axis
1313
pair as a specification for rotation.
@@ -25,7 +25,6 @@
2525
>>> vec = np.array([1, 2, 3]).reshape((3,1)) # column vector
2626
>>> tvec = np.dot(M, vec)
2727
"""
28-
2928
import math
3029

3130
import numpy as np

Diff for: nibabel/rstutils.py

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
* Make ReST table given array of values
44
"""
5-
65
import numpy as np
76

87

Diff for: nibabel/spaces.py

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
mapping), or
2020
* a length 2 sequence with the same information (shape, affine).
2121
"""
22-
2322
from itertools import product
2423

2524
import numpy as np

Diff for: nibabel/tmpdirs.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
# copyright and license terms.
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
9-
"""Contexts for *with* statement providing temporary directories
10-
"""
9+
"""Contexts for *with* statement providing temporary directories"""
1110
import os
1211
import tempfile
1312
from contextlib import contextmanager

Diff for: nibabel/tripwire.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""Class to raise error for missing modules or other misfortunes
2-
"""
1+
"""Class to raise error for missing modules or other misfortunes"""
32
from typing import Any
43

54

Diff for: nibabel/viewers.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
Includes version of OrthoSlicer3D code originally written by our own
44
Paul Ivanov.
55
"""
6-
76
import weakref
87

98
import numpy as np
@@ -14,7 +13,7 @@
1413

1514

1615
class OrthoSlicer3D:
17-
"""Orthogonal-plane slice viewer.
16+
"""Orthogonal-plane slice viewer
1817
1918
OrthoSlicer3d expects 3- or 4-dimensional array data. It treats
2019
4D data as a sequence of 3D spatial volumes, where a slice over the final

Diff for: nibabel/xmlutils.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
# copyright and license terms.
77
#
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
9-
"""
10-
Thin layer around xml.etree.ElementTree, to abstract nibabel xml support.
11-
"""
12-
9+
"""Thin layer around xml.etree.ElementTree, to abstract nibabel xml support"""
1310
from io import BytesIO
1411
from xml.etree.ElementTree import Element, SubElement, tostring # noqa
1512
from xml.parsers.expat import ParserCreate

0 commit comments

Comments
 (0)