Skip to content

Commit 5dc8701

Browse files
authored
Merge pull request #3699 from effigies/fix/deprecations
FIX: Address numpy and traits deprecations
2 parents 1ccee34 + ddb73ac commit 5dc8701

27 files changed

+299
-259
lines changed

Diff for: .github/workflows/contrib.yml

-83
This file was deleted.

Diff for: .github/workflows/tests.yml

+64-75
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
1-
name: Stable tests
2-
3-
# This file tests the claimed support range of nipype including
4-
#
5-
# * Operating systems: Linux, OSX
6-
# * Dependencies: minimum requirements, optional requirements
7-
# * Installation methods: setup.py, sdist, wheel, archive
1+
name: Tox
82

93
on:
104
push:
11-
branches:
12-
- master
13-
- maint/*
14-
tags:
15-
- "*"
5+
branches: [ master, main, 'maint/*' ]
6+
tags: [ '*' ]
167
pull_request:
17-
branches:
18-
- master
19-
- maint/*
8+
branches: [ master, main, 'maint/*' ]
209
schedule:
2110
# 8am EST / 9am EDT Mondays
2211
- cron: "0 13 * * 1"
@@ -26,27 +15,28 @@ defaults:
2615
shell: bash
2716

2817
concurrency:
29-
group: tests-${{ github.ref }}
18+
group: ${{ github.workflow }}-${{ github.ref }}
3019
cancel-in-progress: true
3120

32-
permissions: {}
21+
permissions:
22+
contents: read
23+
24+
env:
25+
# Force tox and pytest to use color
26+
FORCE_COLOR: true
27+
28+
3329
jobs:
3430
build:
35-
permissions:
36-
contents: read # to fetch code (actions/checkout)
37-
3831
runs-on: ubuntu-latest
3932
steps:
4033
- uses: actions/checkout@v4
4134
with:
4235
fetch-depth: 0
43-
- uses: actions/setup-python@v5
44-
with:
45-
python-version: 3
46-
- run: pip install --upgrade build twine
47-
- name: Build sdist and wheel
48-
run: python -m build
49-
- run: twine check dist/*
36+
- name: Install the latest version of uv
37+
uses: astral-sh/setup-uv@v3
38+
- run: uv build
39+
- run: uvx twine check dist/*
5040
- uses: actions/upload-artifact@v4
5141
with:
5242
name: dist
@@ -82,70 +72,51 @@ jobs:
8272
- name: Run tests
8373
run: pytest --doctest-modules -v --pyargs nipype
8474

85-
stable:
75+
test:
8676
# Check each OS, all supported Python, minimum versions and latest releases
87-
permissions:
88-
contents: read # to fetch code (actions/checkout)
89-
9077
runs-on: ${{ matrix.os }}
9178
strategy:
9279
matrix:
93-
os: ["ubuntu-22.04"]
94-
python-version: ["3.9", "3.10", "3.11", "3.12"]
95-
check: ["test"]
96-
pip-flags: [""]
97-
depends: ["REQUIREMENTS"]
98-
deb-depends: [false]
99-
nipype-extras: ["doc,tests,profiler"]
80+
os: ["ubuntu-latest"]
81+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
82+
dependencies: [none, full, pre]
10083
include:
101-
- os: ubuntu-22.04
84+
- os: ubuntu-latest
10285
python-version: "3.9"
103-
check: test
104-
pip-flags: ""
105-
depends: REQUIREMENTS
106-
deb-depends: true
107-
nipype-extras: doc,tests,profiler,duecredit,ssh
108-
- os: ubuntu-20.04
109-
python-version: "3.9"
110-
check: test
111-
pip-flags: ""
112-
depends: REQUIREMENTS
113-
deb-depends: true
114-
nipype-extras: doc,tests,nipy,profiler,duecredit,ssh
86+
dependencies: min
87+
exclude:
88+
# Skip some intermediate versions for full tests
89+
- python-version: "3.10"
90+
dependencies: full
91+
- python-version: "3.11"
92+
dependencies: full
93+
# Do not test pre-releases for versions out of SPEC0
94+
- python-version: "3.9"
95+
dependencies: pre
96+
- python-version: "3.10"
97+
dependencies: pre
98+
11599
env:
116-
DEPENDS: ${{ matrix.depends }}
117-
CHECK_TYPE: ${{ matrix.check }}
118-
EXTRA_PIP_FLAGS: ${{ matrix.pip-flags }}
119-
INSTALL_DEB_DEPENDENCIES: ${{ matrix.deb-depends }}
120-
NIPYPE_EXTRAS: ${{ matrix.nipype-extras }}
121-
INSTALL_TYPE: pip
122-
CI_SKIP_TEST: 1
100+
DEPENDS: ${{ matrix.dependencies }}
123101

124102
steps:
125103
- uses: actions/checkout@v4
104+
- name: Install the latest version of uv
105+
uses: astral-sh/setup-uv@v3
126106
- name: Set up Python ${{ matrix.python-version }}
127107
uses: actions/setup-python@v5
128108
with:
129109
python-version: ${{ matrix.python-version }}
130110
- name: Display Python version
131111
run: python -c "import sys; print(sys.version)"
132-
- name: Create virtual environment
133-
run: tools/ci/create_venv.sh
134-
- name: Build archive
112+
- name: Install tox
135113
run: |
136-
source tools/ci/build_archive.sh
137-
echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
138-
- name: Install Debian dependencies
139-
run: tools/ci/install_deb_dependencies.sh
140-
if: ${{ matrix.os == 'ubuntu-latest' }}
141-
- name: Install dependencies
142-
run: tools/ci/install_dependencies.sh
143-
- name: Install Nipype
144-
run: tools/ci/install.sh
145-
- name: Run tests
146-
run: tools/ci/check.sh
147-
if: ${{ matrix.check != 'skiptests' }}
148-
- uses: codecov/codecov-action@v5
114+
uv tool install tox --with=tox-uv --with=tox-gh-actions
115+
- name: Show tox config
116+
run: tox c
117+
- name: Run tox
118+
run: tox -v --exit-and-dump-after 1200
119+
- uses: codecov/codecov-action@v4
149120
with:
150121
token: ${{ secrets.CODECOV_TOKEN }}
151122
if: ${{ always() }}
@@ -159,7 +130,7 @@ jobs:
159130
publish:
160131
runs-on: ubuntu-latest
161132
environment: "Package deployment"
162-
needs: [stable, test-package]
133+
needs: [test, test-package]
163134
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
164135
steps:
165136
- uses: actions/download-artifact@v4
@@ -170,3 +141,21 @@ jobs:
170141
with:
171142
user: __token__
172143
password: ${{ secrets.PYPI_API_TOKEN }}
144+
145+
checks:
146+
runs-on: 'ubuntu-latest'
147+
continue-on-error: true
148+
strategy:
149+
matrix:
150+
check: ['specs', 'style']
151+
152+
steps:
153+
- uses: actions/checkout@v4
154+
- name: Install the latest version of uv
155+
uses: astral-sh/setup-uv@v3
156+
- name: Show tox config
157+
run: uvx tox c
158+
- name: Show tox config (this call)
159+
run: uvx tox c -e ${{ matrix.check }}
160+
- name: Run check
161+
run: uvx tox -e ${{ matrix.check }}

Diff for: nipype/algorithms/confounds.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def _run_interface(self, runtime):
188188

189189
if self.inputs.save_std:
190190
out_file = self._gen_fname("dvars_std", ext="tsv")
191-
np.savetxt(out_file, dvars[0], fmt=b"%0.6f")
191+
np.savetxt(out_file, dvars[0], fmt="%0.6f")
192192
self._results["out_std"] = out_file
193193

194194
if self.inputs.save_plot:
@@ -228,7 +228,7 @@ def _run_interface(self, runtime):
228228

229229
if self.inputs.save_vxstd:
230230
out_file = self._gen_fname("dvars_vxstd", ext="tsv")
231-
np.savetxt(out_file, dvars[2], fmt=b"%0.6f")
231+
np.savetxt(out_file, dvars[2], fmt="%0.6f")
232232
self._results["out_vxstd"] = out_file
233233

234234
if self.inputs.save_plot:
@@ -251,8 +251,8 @@ def _run_interface(self, runtime):
251251
np.savetxt(
252252
out_file,
253253
np.vstack(dvars).T,
254-
fmt=b"%0.8f",
255-
delimiter=b"\t",
254+
fmt="%0.8f",
255+
delimiter="\t",
256256
header="std DVARS\tnon-std DVARS\tvx-wise std DVARS",
257257
comments="",
258258
)
@@ -689,7 +689,7 @@ def _run_interface(self, runtime):
689689
np.savetxt(
690690
components_file,
691691
components,
692-
fmt=b"%.10f",
692+
fmt="%.10f",
693693
delimiter="\t",
694694
header="\t".join(components_header),
695695
comments="",
@@ -729,7 +729,7 @@ def _run_interface(self, runtime):
729729
np.savetxt(
730730
self._results["pre_filter_file"],
731731
filter_basis,
732-
fmt=b"%.10f",
732+
fmt="%.10f",
733733
delimiter="\t",
734734
header="\t".join(header),
735735
comments="",

Diff for: nipype/algorithms/rapidart.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ class ArtifactDetectInputSpec(BaseInterfaceInputSpec):
189189
desc="Source of movement parameters",
190190
mandatory=True,
191191
)
192-
use_differences = traits.ListBool(
192+
use_differences = traits.List(
193+
traits.Bool,
193194
[True, False],
194195
minlen=2,
195196
maxlen=2,
@@ -600,10 +601,10 @@ def _detect_outliers_core(self, imgfile, motionfile, runidx, cwd=None):
600601
outliers = np.unique(np.union1d(iidx, np.union1d(tidx, ridx)))
601602

602603
# write output to outputfile
603-
np.savetxt(artifactfile, outliers, fmt=b"%d", delimiter=" ")
604-
np.savetxt(intensityfile, g, fmt=b"%.2f", delimiter=" ")
604+
np.savetxt(artifactfile, outliers, fmt="%d", delimiter=" ")
605+
np.savetxt(intensityfile, g, fmt="%.2f", delimiter=" ")
605606
if self.inputs.use_norm:
606-
np.savetxt(normfile, normval, fmt=b"%.4f", delimiter=" ")
607+
np.savetxt(normfile, normval, fmt="%.4f", delimiter=" ")
607608

608609
if isdefined(self.inputs.save_plot) and self.inputs.save_plot:
609610
import matplotlib

Diff for: nipype/algorithms/tests/test_auto_ArtifactDetect.py

-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ def test_ArtifactDetect_inputs():
4848
xor=["norm_threshold"],
4949
),
5050
use_differences=dict(
51-
maxlen=2,
52-
minlen=2,
5351
usedefault=True,
5452
),
5553
use_norm=dict(

Diff for: nipype/conftest.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import shutil
33
from tempfile import mkdtemp
44
import pytest
5-
import numpy
5+
import numpy as np
66
import py.path as pp
77

88
NIPYPE_DATADIR = os.path.realpath(
@@ -15,12 +15,17 @@
1515

1616
@pytest.fixture(autouse=True)
1717
def add_np(doctest_namespace):
18-
doctest_namespace["np"] = numpy
18+
doctest_namespace["np"] = np
1919
doctest_namespace["os"] = os
2020
doctest_namespace["pytest"] = pytest
2121
doctest_namespace["datadir"] = data_dir
2222

2323

24+
@pytest.fixture(scope='session', autouse=True)
25+
def legacy_printoptions():
26+
np.set_printoptions(legacy='1.21')
27+
28+
2429
@pytest.fixture(autouse=True)
2530
def _docdir(request):
2631
"""Grabbed from https://stackoverflow.com/a/46991331"""

0 commit comments

Comments
 (0)