Skip to content

Commit a33a2af

Browse files
committed
Merge remote-tracking branch 'upstream/master' into ResourceWarning_unclosed_file
2 parents 07e25d0 + d0e6363 commit a33a2af

File tree

226 files changed

+9933
-8625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

226 files changed

+9933
-8625
lines changed

.git-blame-ignore-revs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Thu Dec 29 22:53:17 2022 -0500 - [email protected] - STY: Reduce array().astype() and similar constructs
2+
bf298113da99079c9c7b5e1690e41879828cd472
3+
# Thu Dec 29 22:32:46 2022 -0500 - [email protected] - STY: pyupgrade --py37-plus
4+
4481a4c2640bd4be6e9c468e550d01aae448ab99
5+
# Fri Dec 30 11:01:19 2022 -0500 - [email protected] - STY: Run vanilla blue
6+
6b0ddd23b1da1df7ca9ae275673f82bfa20a754c
7+
# Thu Dec 29 21:46:13 2022 -0500 - [email protected] - STY: Manual, blue-compatible touchups
8+
263fca9bf6d4ca314a5a322b4824d6f53d0589df
9+
# Thu Dec 29 21:32:00 2022 -0500 - [email protected] - STY: isort
10+
0ab2856cac4d4baae7ab3e2f6d58421db55d807f
11+
# Thu Dec 29 21:30:29 2022 -0500 - [email protected] - STY: blue
12+
1a8dd302ff85b1136c81d492509b80e7748339f0

.github/workflows/misc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
matrix:
2525
python-version: ["3.10"]
2626
install: ['pip']
27-
check: ['style', 'doc']
27+
check: ['style', 'doctest']
2828
pip-flags: ['']
2929
depends: ['REQUIREMENTS']
3030
env:

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Thumbs.db
8383
# Things specific to this project #
8484
###################################
8585
doc/source/reference
86+
doc/source/generated
8687
venv/
8788
.buildbot.patch
8889
.vscode

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ distclean: clean
7878
$(WWW_DIR):
7979
if [ ! -d $(WWW_DIR) ]; then mkdir -p $(WWW_DIR); fi
8080

81+
.git-blame-ignore-revs:
82+
git log --grep "\[git-blame-ignore-rev\]" --pretty=format:"# %ad - %ae - %s%n%H" \
83+
> .git-blame-ignore-revs
8184

8285
#
8386
# Tests
@@ -288,4 +291,4 @@ rm-orig:
288291
# Remove .orig temporary diff files generated by git
289292
find . -name "*.orig" -print | grep -v "fsaverage" | xargs rm
290293

291-
.PHONY: orig-src pylint all build
294+
.PHONY: orig-src pylint all build .git-blame-ignore-revs

doc-requirements.txt

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# Requirements for building docs
1+
# Auto-generated by tools/update_requirements.py
22
-r requirements.txt
3-
sphinx<3
3+
matplotlib >= 1.5.3
44
numpydoc
5+
sphinx ~= 5.3
56
texext
6-
matplotlib >=1.3.1
7+
tomli; python_version < "3.11"

doc/source/conf.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@
1919
# All configuration values have a default; values that are commented out
2020
# serve to show the default.
2121

22-
import sys
2322
import os
23+
from pathlib import Path
2424
from runpy import run_path
25-
from configparser import ConfigParser
25+
26+
try:
27+
import tomllib
28+
except ImportError:
29+
import tomli as tomllib
2630

2731
# Check for external Sphinx extensions we depend on
2832
try:
@@ -41,11 +45,6 @@
4145
raise RuntimeError('Need nibabel on Python PATH; consider "make htmldoc" '
4246
'from nibabel root directory')
4347

44-
# If extensions (or modules to document with autodoc) are in another directory,
45-
# add these directories to sys.path here. If the directory is relative to the
46-
# documentation root, use os.path.abspath to make it absolute, like shown here.
47-
# sys.path.append(os.path.abspath('../sphinxext'))
48-
4948
# -- General configuration ----------------------------------------------------
5049

5150
# We load the nibabel release info into a dict by explicit execution
@@ -56,15 +55,15 @@
5655
fobj.write(rel['long_description'])
5756

5857
# Load metadata from setup.cfg
59-
config = ConfigParser()
60-
config.read(os.path.join('..', '..', 'setup.cfg'))
61-
metadata = config['metadata']
58+
with open(Path("../../pyproject.toml"), 'rb') as fobj:
59+
pyproject = tomllib.load(fobj)
60+
authors = pyproject["project"]["authors"][0]
6261

6362
# Add any Sphinx extension module names here, as strings. They can be
6463
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
6564
extensions = ['sphinx.ext.autodoc',
6665
'sphinx.ext.doctest',
67-
#'sphinx.ext.intersphinx',
66+
'sphinx.ext.intersphinx',
6867
'sphinx.ext.todo',
6968
'sphinx.ext.mathjax',
7069
'sphinx.ext.inheritance_diagram',
@@ -74,9 +73,10 @@
7473
'matplotlib.sphinxext.plot_directive',
7574
]
7675

77-
# the following doesn't work with sphinx < 1.0, but will make a separate
78-
# sphinx-autogen run obsolete in the future
79-
#autosummary_generate = True
76+
# Autosummary always wants to use a `generated/` directory.
77+
# We generate with `make api-stamp`
78+
# This could change in the future
79+
autosummary_generate = False
8080

8181
# Add any paths that contain templates here, relative to this directory.
8282
templates_path = ['_templates']
@@ -92,7 +92,7 @@
9292

9393
# General information about the project.
9494
project = u'NiBabel'
95-
copyright = f"2006-2022, {metadata['maintainer']} <{metadata['author_email']}>"
95+
copyright = f"2006-2022, {authors['name']} <{authors['email']}>"
9696

9797
# The version info for the project you're documenting, acts as replacement for
9898
# |version| and |release|, also used in various other places throughout the
@@ -272,7 +272,7 @@
272272

273273

274274
# Example configuration for intersphinx: refer to the Python standard library.
275-
intersphinx_mapping = {'https://docs.python.org/': None}
275+
intersphinx_mapping = {'https://docs.python.org/3/': None}
276276

277277
# Config of plot_directive
278278
plot_include_source = True

doc/source/devel/biaps/biap_0003.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ The base level header will usually also have image metadata fields giving
199199
information about the whole image. A field is an "image metadata field" if it
200200
is defined at the top level of the header. For example::
201201

202-
>>> hdr = dict(nipy_header_version='1.0',
203-
... Manufacturer="SIEMENS")
202+
>>> hdr = dict(nipy_header_version='1.0',
203+
... Manufacturer="SIEMENS")
204204

205205
All image metadata fields are optional.
206206

@@ -635,7 +635,7 @@ Use case
635635
^^^^^^^^
636636

637637
When doing motion correction on a 4D image, we calculate the required affine
638-
transformation from |--| say |--| the second image to the first image; the
638+
transformation from, say, the second image to the first image; the
639639
third image to the first image; etc. If there are N volumes in the 4D image,
640640
we would need to store N-1 affine transformations. If we have registered to
641641
the mean volume of the volume series instead of one of the volumes in the

doc/source/devel/biaps/biap_0004.rst

+1
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ Improving access to varying meta data through the Nifti
221221

222222
Currently, when accessing varying meta data through the `get_meta` method
223223
you can only get one value at a time::
224+
224225
>>> echo_times = [nii.get_meta('EchoTime', (0, 0, 0, idx))
225226
for idx in xrange(data.shape[-1])]
226227

doc/source/devel/biaps/biap_0006.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ In NIfTI:
193193

194194
We saw above that the MGH format refers to a volume (in our sense) as a
195195
*frame*. ECAT has the same usage - a frame is a 3D volume. The fmristat
196-
software uses frame in the same sense |--| e.g. `line 32 of example.m
196+
software uses frame in the same sense, e.g., `line 32 of example.m
197197
<https://github.com/matthew-brett/fmristat/blob/master/fmristat/example.m#L32>`_.
198198

199199
Unfortunately DICOM appears to use "frame" to mean a 2D slice. For example,

doc/source/devel/devdiscuss.rst

+4
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ progress.
2222
spm_use
2323
modified_images
2424
data_pkg_design
25+
data_pkg_discuss
26+
data_pkg_uses
27+
scaling
28+
bv_formats

doc/source/devel/image_design.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:orphan:
2+
13
########################
24
The nibabel image object
35
########################

doc/source/installing_data.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
:orphan:
2+
13
.. _installing-data:
24

35
Installing data packages

doc/source/old/ioimplementation.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.. -*- mode: rst -*-
22
3+
:orphan:
4+
35
##################################################
46
Relationship between images and io implementations
57
##################################################

doc/tools/build_modref_templates.py

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def abort(error):
8383
r'\.info.*$',
8484
r'\.pkg_info.*$',
8585
r'\.py3k.*$',
86+
r'\._version.*$',
8687
]
8788
docwriter.write_api_docs(outdir)
8889
docwriter.write_index(outdir, 'index', relative_to=outdir)

nibabel/__init__.py

+50-34
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99

1010
import os
1111

12-
from .pkg_info import __version__
1312
from .info import long_description as __doc__
13+
from .pkg_info import __version__
14+
1415
__doc__ += """
1516
Quickstart
1617
==========
@@ -38,32 +39,39 @@
3839

3940
# module imports
4041
from . import analyze as ana
41-
from . import spm99analyze as spm99
42-
from . import spm2analyze as spm2
42+
from . import ecat, mriutils
4343
from . import nifti1 as ni1
44-
from . import ecat
44+
from . import spm2analyze as spm2
45+
from . import spm99analyze as spm99
46+
from . import streamlines, viewers
47+
48+
# isort: split
49+
4550
# object imports
46-
from .fileholders import FileHolder, FileHolderError
47-
from .loadsave import load, save
48-
from .arrayproxy import is_proxy
4951
from .analyze import AnalyzeHeader, AnalyzeImage
50-
from .spm99analyze import Spm99AnalyzeHeader, Spm99AnalyzeImage
51-
from .spm2analyze import Spm2AnalyzeHeader, Spm2AnalyzeImage
52-
from .nifti1 import Nifti1Header, Nifti1Image, Nifti1Pair
53-
from .nifti2 import Nifti2Header, Nifti2Image, Nifti2Pair
54-
from .minc1 import Minc1Image
55-
from .minc2 import Minc2Image
52+
from .arrayproxy import is_proxy
5653
from .cifti2 import Cifti2Header, Cifti2Image
57-
from .gifti import GiftiImage
54+
from .fileholders import FileHolder, FileHolderError
5855
from .freesurfer import MGHImage
59-
from .funcs import (squeeze_image, concat_images, four_to_three,
60-
as_closest_canonical)
61-
from .orientations import (io_orientation, flip_axis, OrientationError,
62-
apply_orientation, aff2axcodes)
56+
from .funcs import as_closest_canonical, concat_images, four_to_three, squeeze_image
57+
from .gifti import GiftiImage
6358
from .imageclasses import all_image_classes
64-
from . import mriutils
65-
from . import streamlines
66-
from . import viewers
59+
from .loadsave import load, save
60+
from .minc1 import Minc1Image
61+
from .minc2 import Minc2Image
62+
from .nifti1 import Nifti1Header, Nifti1Image, Nifti1Pair
63+
from .nifti2 import Nifti2Header, Nifti2Image, Nifti2Pair
64+
from .orientations import (
65+
OrientationError,
66+
aff2axcodes,
67+
apply_orientation,
68+
flip_axis,
69+
io_orientation,
70+
)
71+
from .spm2analyze import Spm2AnalyzeHeader, Spm2AnalyzeImage
72+
from .spm99analyze import Spm99AnalyzeHeader, Spm99AnalyzeImage
73+
74+
# isort: split
6775

6876
from .pkg_info import get_pkg_info as _get_pkg_info
6977

@@ -72,9 +80,15 @@ def get_info():
7280
return _get_pkg_info(os.path.dirname(__file__))
7381

7482

75-
def test(label=None, verbose=1, extra_argv=None,
76-
doctests=False, coverage=False, raise_warnings=None,
77-
timer=False):
83+
def test(
84+
label=None,
85+
verbose=1,
86+
extra_argv=None,
87+
doctests=False,
88+
coverage=False,
89+
raise_warnings=None,
90+
timer=False,
91+
):
7892
"""
7993
Run tests for nibabel using pytest
8094
@@ -107,29 +121,30 @@ def test(label=None, verbose=1, extra_argv=None,
107121
Returns the result of running the tests as a ``pytest.ExitCode`` enum
108122
"""
109123
import pytest
124+
110125
args = []
111126

112127
if label is not None:
113-
raise NotImplementedError("Labels cannot be set at present")
128+
raise NotImplementedError('Labels cannot be set at present')
114129

115130
verbose = int(verbose)
116131
if verbose > 0:
117-
args.append("-" + "v" * verbose)
132+
args.append('-' + 'v' * verbose)
118133
elif verbose < 0:
119-
args.append("-" + "q" * -verbose)
134+
args.append('-' + 'q' * -verbose)
120135

121136
if extra_argv:
122137
args.extend(extra_argv)
123138
if doctests:
124-
args.append("--doctest-modules")
139+
args.append('--doctest-modules')
125140
if coverage:
126-
args.extend(["--cov", "nibabel"])
141+
args.extend(['--cov', 'nibabel'])
127142
if raise_warnings is not None:
128-
raise NotImplementedError("Warning filters are not implemented")
143+
raise NotImplementedError('Warning filters are not implemented')
129144
if timer:
130-
raise NotImplementedError("Timing is not implemented")
145+
raise NotImplementedError('Timing is not implemented')
131146

132-
args.extend(["--pyargs", "nibabel"])
147+
args.extend(['--pyargs', 'nibabel'])
133148

134149
return pytest.main(args=args)
135150

@@ -157,9 +172,10 @@ def bench(label=None, verbose=1, extra_argv=None):
157172
Returns the result of running the tests as a ``pytest.ExitCode`` enum
158173
"""
159174
from pkg_resources import resource_filename
160-
config = resource_filename("nibabel", "benchmarks/pytest.benchmark.ini")
175+
176+
config = resource_filename('nibabel', 'benchmarks/pytest.benchmark.ini')
161177
args = []
162178
if extra_argv is not None:
163179
args.extend(extra_argv)
164-
args.extend(["-c", config])
180+
args.extend(['-c', config])
165181
return test(label, verbose, extra_argv=args)

0 commit comments

Comments
 (0)