Skip to content

Commit

Permalink
Merge pull request #3699 from effigies/fix/deprecations
Browse files Browse the repository at this point in the history
FIX: Address numpy and traits deprecations
  • Loading branch information
effigies authored Nov 18, 2024
2 parents 1ccee34 + ddb73ac commit 5dc8701
Show file tree
Hide file tree
Showing 27 changed files with 299 additions and 259 deletions.
83 changes: 0 additions & 83 deletions .github/workflows/contrib.yml

This file was deleted.

139 changes: 64 additions & 75 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
name: Stable tests

# This file tests the claimed support range of nipype including
#
# * Operating systems: Linux, OSX
# * Dependencies: minimum requirements, optional requirements
# * Installation methods: setup.py, sdist, wheel, archive
name: Tox

on:
push:
branches:
- master
- maint/*
tags:
- "*"
branches: [ master, main, 'maint/*' ]
tags: [ '*' ]
pull_request:
branches:
- master
- maint/*
branches: [ master, main, 'maint/*' ]
schedule:
# 8am EST / 9am EDT Mondays
- cron: "0 13 * * 1"
Expand All @@ -26,27 +15,28 @@ defaults:
shell: bash

concurrency:
group: tests-${{ github.ref }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions: {}
permissions:
contents: read

env:
# Force tox and pytest to use color
FORCE_COLOR: true


jobs:
build:
permissions:
contents: read # to fetch code (actions/checkout)

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: 3
- run: pip install --upgrade build twine
- name: Build sdist and wheel
run: python -m build
- run: twine check dist/*
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
- run: uv build
- run: uvx twine check dist/*
- uses: actions/upload-artifact@v4
with:
name: dist
Expand Down Expand Up @@ -82,70 +72,51 @@ jobs:
- name: Run tests
run: pytest --doctest-modules -v --pyargs nipype

stable:
test:
# Check each OS, all supported Python, minimum versions and latest releases
permissions:
contents: read # to fetch code (actions/checkout)

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-22.04"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
check: ["test"]
pip-flags: [""]
depends: ["REQUIREMENTS"]
deb-depends: [false]
nipype-extras: ["doc,tests,profiler"]
os: ["ubuntu-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
dependencies: [none, full, pre]
include:
- os: ubuntu-22.04
- os: ubuntu-latest
python-version: "3.9"
check: test
pip-flags: ""
depends: REQUIREMENTS
deb-depends: true
nipype-extras: doc,tests,profiler,duecredit,ssh
- os: ubuntu-20.04
python-version: "3.9"
check: test
pip-flags: ""
depends: REQUIREMENTS
deb-depends: true
nipype-extras: doc,tests,nipy,profiler,duecredit,ssh
dependencies: min
exclude:
# Skip some intermediate versions for full tests
- python-version: "3.10"
dependencies: full
- python-version: "3.11"
dependencies: full
# Do not test pre-releases for versions out of SPEC0
- python-version: "3.9"
dependencies: pre
- python-version: "3.10"
dependencies: pre

env:
DEPENDS: ${{ matrix.depends }}
CHECK_TYPE: ${{ matrix.check }}
EXTRA_PIP_FLAGS: ${{ matrix.pip-flags }}
INSTALL_DEB_DEPENDENCIES: ${{ matrix.deb-depends }}
NIPYPE_EXTRAS: ${{ matrix.nipype-extras }}
INSTALL_TYPE: pip
CI_SKIP_TEST: 1
DEPENDS: ${{ matrix.dependencies }}

steps:
- uses: actions/checkout@v4
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Create virtual environment
run: tools/ci/create_venv.sh
- name: Build archive
- name: Install tox
run: |
source tools/ci/build_archive.sh
echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
- name: Install Debian dependencies
run: tools/ci/install_deb_dependencies.sh
if: ${{ matrix.os == 'ubuntu-latest' }}
- name: Install dependencies
run: tools/ci/install_dependencies.sh
- name: Install Nipype
run: tools/ci/install.sh
- name: Run tests
run: tools/ci/check.sh
if: ${{ matrix.check != 'skiptests' }}
- uses: codecov/codecov-action@v5
uv tool install tox --with=tox-uv --with=tox-gh-actions
- name: Show tox config
run: tox c
- name: Run tox
run: tox -v --exit-and-dump-after 1200
- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
if: ${{ always() }}
Expand All @@ -159,7 +130,7 @@ jobs:
publish:
runs-on: ubuntu-latest
environment: "Package deployment"
needs: [stable, test-package]
needs: [test, test-package]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v4
Expand All @@ -170,3 +141,21 @@ jobs:
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

checks:
runs-on: 'ubuntu-latest'
continue-on-error: true
strategy:
matrix:
check: ['specs', 'style']

steps:
- uses: actions/checkout@v4
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
- name: Show tox config
run: uvx tox c
- name: Show tox config (this call)
run: uvx tox c -e ${{ matrix.check }}
- name: Run check
run: uvx tox -e ${{ matrix.check }}
12 changes: 6 additions & 6 deletions nipype/algorithms/confounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def _run_interface(self, runtime):

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

if self.inputs.save_plot:
Expand Down Expand Up @@ -228,7 +228,7 @@ def _run_interface(self, runtime):

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

if self.inputs.save_plot:
Expand All @@ -251,8 +251,8 @@ def _run_interface(self, runtime):
np.savetxt(
out_file,
np.vstack(dvars).T,
fmt=b"%0.8f",
delimiter=b"\t",
fmt="%0.8f",
delimiter="\t",
header="std DVARS\tnon-std DVARS\tvx-wise std DVARS",
comments="",
)
Expand Down Expand Up @@ -689,7 +689,7 @@ def _run_interface(self, runtime):
np.savetxt(
components_file,
components,
fmt=b"%.10f",
fmt="%.10f",
delimiter="\t",
header="\t".join(components_header),
comments="",
Expand Down Expand Up @@ -729,7 +729,7 @@ def _run_interface(self, runtime):
np.savetxt(
self._results["pre_filter_file"],
filter_basis,
fmt=b"%.10f",
fmt="%.10f",
delimiter="\t",
header="\t".join(header),
comments="",
Expand Down
9 changes: 5 additions & 4 deletions nipype/algorithms/rapidart.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ class ArtifactDetectInputSpec(BaseInterfaceInputSpec):
desc="Source of movement parameters",
mandatory=True,
)
use_differences = traits.ListBool(
use_differences = traits.List(
traits.Bool,
[True, False],
minlen=2,
maxlen=2,
Expand Down Expand Up @@ -600,10 +601,10 @@ def _detect_outliers_core(self, imgfile, motionfile, runidx, cwd=None):
outliers = np.unique(np.union1d(iidx, np.union1d(tidx, ridx)))

# write output to outputfile
np.savetxt(artifactfile, outliers, fmt=b"%d", delimiter=" ")
np.savetxt(intensityfile, g, fmt=b"%.2f", delimiter=" ")
np.savetxt(artifactfile, outliers, fmt="%d", delimiter=" ")
np.savetxt(intensityfile, g, fmt="%.2f", delimiter=" ")
if self.inputs.use_norm:
np.savetxt(normfile, normval, fmt=b"%.4f", delimiter=" ")
np.savetxt(normfile, normval, fmt="%.4f", delimiter=" ")

if isdefined(self.inputs.save_plot) and self.inputs.save_plot:
import matplotlib
Expand Down
2 changes: 0 additions & 2 deletions nipype/algorithms/tests/test_auto_ArtifactDetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ def test_ArtifactDetect_inputs():
xor=["norm_threshold"],
),
use_differences=dict(
maxlen=2,
minlen=2,
usedefault=True,
),
use_norm=dict(
Expand Down
9 changes: 7 additions & 2 deletions nipype/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import shutil
from tempfile import mkdtemp
import pytest
import numpy
import numpy as np
import py.path as pp

NIPYPE_DATADIR = os.path.realpath(
Expand All @@ -15,12 +15,17 @@

@pytest.fixture(autouse=True)
def add_np(doctest_namespace):
doctest_namespace["np"] = numpy
doctest_namespace["np"] = np
doctest_namespace["os"] = os
doctest_namespace["pytest"] = pytest
doctest_namespace["datadir"] = data_dir


@pytest.fixture(scope='session', autouse=True)
def legacy_printoptions():
np.set_printoptions(legacy='1.21')


@pytest.fixture(autouse=True)
def _docdir(request):
"""Grabbed from https://stackoverflow.com/a/46991331"""
Expand Down
Loading

0 comments on commit 5dc8701

Please sign in to comment.