Skip to content

Commit 3a8bd18

Browse files
Numpy 2.0 + scipy + matplotlib pre-release workflow (#89)
* pin pytest to 8.0 and above * move conftest.py to root and turn warnings into errors * add workflow testing against numpy 2.0 * skip coverage * fix config file used * also install pip-pre scipy and matplotlib * scikit-learn also for nilearn compatibility with numpy 2.0 * don't run nilearn tests on pip-pre * run 3.9 and 3.12 on circle and 3.7 compat on gh * fix workflow name * fix: importorskip is not a mark decorator * catch user warning * fix deprecated readfp * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * ignore conftest in module discovery * fix uninstall step of nilearn * try again to rm nilearn * fix module discovery logic * fix numpy deprecation of np.NINF and np.trapz * fix missed importorskip("nilearn") * fix deprecation of find_module in module discovery logic * fix compatibility trapz <-> trapezoid * fix compatibility function * add missed pytest.importorskip("nilearn") * fix imports, drop pkg_utils entirely * fix missed imports * rm unused variable * use relative imports and fix circular import and namespace * revert version import * close log file handler * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix missed importorskip("nilearn") * fix codecov yml * suppress sphinx gallery warning * mv trapezoid_compat * trigger ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent cb99342 commit 3a8bd18

File tree

20 files changed

+230
-93
lines changed

20 files changed

+230
-93
lines changed

.circleci/config.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ orbs:
1515
# Define a job to be invoked later in a workflow.
1616
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs
1717
jobs:
18-
test37: # This is the name of the job, feel free to change it to better match what you're trying to do!
18+
test39: # This is the name of the job, feel free to change it to better match what you're trying to do!
1919
# These next lines defines a Docker executors: https://circleci.com/docs/2.0/executor-types/
2020
# You can specify an image from Dockerhub or use one of the convenience images from CircleCI's Developer Hub
2121
# A list of available CircleCI Docker convenience images are available here: https://circleci.com/developer/images/image/cimg/python
2222
# The executor is the environment in which the steps below will be executed - below will use a python 3.6.14 container
2323
# Change the version below to your required version of python
2424
docker:
25-
- image: cimg/python:3.7
25+
- image: cimg/python:3.9
2626
working_directory: /tmp/src/nigsp
2727
resource_class: medium
2828
# Checkout the code as the first step. This is a dedicated CircleCI step.
@@ -58,9 +58,9 @@ jobs:
5858
paths:
5959
- src/coverage/.coverage.py37
6060

61-
test310:
61+
test312:
6262
docker:
63-
- image: cimg/python:3.10
63+
- image: cimg/python:3.12
6464
working_directory: /tmp/src/nigsp
6565
resource_class: medium
6666
steps:
@@ -85,7 +85,7 @@ jobs:
8585

8686
style_check:
8787
docker:
88-
- image: cimg/python:3.7
88+
- image: cimg/python:3.11
8989
working_directory: /tmp/src/nigsp
9090
resource_class: small
9191
steps:
@@ -105,7 +105,7 @@ jobs:
105105
merge_coverage:
106106
working_directory: /tmp/src/nigsp
107107
docker:
108-
- image: cimg/python:3.10
108+
- image: cimg/python:3.11
109109
resource_class: small
110110
steps:
111111
- attach_workspace:
@@ -133,13 +133,13 @@ workflows:
133133
# Inside the workflow, you define the jobs you want to run.
134134
jobs:
135135
- style_check
136-
- test37:
136+
- test39:
137137
requires:
138138
- style_check
139-
- test310:
139+
- test312:
140140
requires:
141141
- style_check
142142
- merge_coverage:
143143
requires:
144-
- test37
145-
- test310
144+
- test39
145+
- test312

.github/workflows/pytest.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: pytest
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }}
4+
cancel-in-progress: true
5+
on: # yamllint disable-line rule:truthy
6+
pull_request:
7+
push:
8+
branches: [main]
9+
workflow_dispatch:
10+
schedule:
11+
- cron: '0 8 * * 1'
12+
13+
jobs:
14+
pytest-compat:
15+
timeout-minutes: 30
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: ["3.7"]
20+
name: pip compat - py${{ matrix.python-version }}
21+
runs-on: ubuntu-latest
22+
defaults:
23+
run:
24+
shell: bash
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
- name: Setup Python ${{ matrix.python-version }}
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
architecture: 'x64'
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install --progress-bar off --upgrade pip setuptools
36+
python -m pip install --progress-bar off .[all,style]
37+
python -m pip install --progress-bar off pytest pytest-cov coverage
38+
- name: Run pytest
39+
run: pytest nigsp --cov=nigsp --cov-report=xml --cov-config=setup.cfg
40+
- name: Upload to codecov
41+
uses: codecov/codecov-action@v4
42+
with:
43+
files: ./coverage.xml
44+
flags: unittests # optional
45+
name: codecov-umbrella # optional
46+
token: ${{ secrets.CODECOV_TOKEN }}
47+
verbose: true # optional (default = false)
48+
pytest-pip-pre:
49+
timeout-minutes: 30
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
python-version: ["3.11"]
54+
name: pip pre-release - py${{ matrix.python-version }}
55+
runs-on: ubuntu-latest
56+
defaults:
57+
run:
58+
shell: bash
59+
steps:
60+
- name: Checkout repository
61+
uses: actions/checkout@v4
62+
- name: Setup Python ${{ matrix.python-version }}
63+
uses: actions/setup-python@v5
64+
with:
65+
python-version: ${{ matrix.python-version }}
66+
architecture: 'x64'
67+
- name: Install dependencies
68+
run: |
69+
python -m pip install --progress-bar off --upgrade pip setuptools
70+
python -m pip install --progress-bar off .[test]
71+
python -m pip install matplotlib
72+
python -m pip install --progress-bar off --upgrade --no-deps --pre --only-binary :all: -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --timeout=180 matplotlib
73+
python -m pip install --progress-bar off --upgrade --pre --only-binary :all: -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --timeout=180 numpy scipy
74+
python -m pip uninstall -y nilearn
75+
- name: Run pytest
76+
run: pytest nigsp --cov=nigsp --cov-report=xml --cov-config=setup.cfg
77+
- name: Upload to codecov
78+
uses: codecov/codecov-action@v4
79+
with:
80+
files: ./coverage.xml
81+
flags: unittests # optional
82+
name: codecov-umbrella # optional
83+
token: ${{ secrets.CODECOV_TOKEN }}
84+
verbose: true # optional (default = false)

codecov.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
codecov:
22
branch: master
33
strict_yaml_branch: master
4-
require_ci_to_pass: yes
4+
require_ci_to_pass: true
55
bot: "codecov-io"
66
max_report_age: 48
7-
disable_default_path_fixes: no
7+
disable_default_path_fixes: false
88

99
coverage:
1010
precision: 2
@@ -40,4 +40,4 @@ ignore:
4040
comment:
4141
layout: "reach,diff,flags,tree"
4242
behavior: default
43-
require_changes: no
43+
require_changes: false

docs/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@
8989
nitpicky = True
9090
nitpick_ignore = []
9191

92+
# list of warning types to suppress
93+
suppress_warnings = ["config.cache"]
94+
9295
# -- Options for HTML output -------------------------------------------------
9396

9497
# The theme to use for HTML and HTML Help pages. See the documentation for

nigsp/__init__.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
"""Hopefully importing everything."""
2-
3-
import pkgutil
4-
1+
from . import (
2+
blocks,
3+
cli,
4+
due,
5+
io,
6+
objects,
7+
operations,
8+
references,
9+
utils,
10+
viz,
11+
workflow,
12+
)
513
from ._version import get_versions
6-
from .operations import graph, laplacian, metrics, nifti, surrogates, timeseries
7-
8-
SKIP_MODULES = ["tests"]
914

1015
__version__ = get_versions()["version"]
1116
del get_versions
12-
13-
__all__ = []
14-
for loader, module_name, is_pkg in pkgutil.walk_packages(__path__):
15-
if "tests" not in module_name:
16-
__all__.append(module_name)
17-
_module = loader.find_module(module_name).load_module(module_name)
18-
globals()[module_name] = _module

nigsp/blocks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
import logging
1212

13-
from nigsp import io, viz
14-
from nigsp.operations import nifti
13+
from . import io, viz
14+
from .operations import nifti
1515

1616
LGR = logging.getLogger(__name__)
1717

nigsp/cli/run.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@
33

44
import argparse
55

6-
from nigsp import __version__
6+
from .. import __version__
77

88

99
def _get_parser():
10-
"""
11-
Parse command line inputs for this function.
10+
"""Parse command line inputs for this function.
1211
1312
Returns
1413
-------
1514
parser.parse_args() : argparse dict
16-
1715
"""
1816
parser = argparse.ArgumentParser(
1917
description=(
@@ -251,8 +249,7 @@ def _get_parser():
251249
if __name__ == "__main__":
252250
raise RuntimeError(
253251
"nigsp/cli/run.py should not be run directly;\n"
254-
"Please `pip install` nigsp and use the "
255-
"`nigsp` command"
252+
"Please `pip install` nigsp and use the `nigsp` command."
256253
)
257254

258255

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
1-
"""
2-
This configuration test module was taken from phys2bids.
3-
Credit to the original author(s) and to the phys2bids community.
4-
"""
1+
from __future__ import annotations # c.f. PEP 563, PEP 649
52

63
import os
74
import ssl
5+
from typing import TYPE_CHECKING
86
from urllib.request import urlretrieve
97

10-
import pytest
8+
from pytest import fixture
9+
10+
if TYPE_CHECKING:
11+
from pytest import Config
12+
13+
14+
def pytest_configure(config: Config) -> None:
15+
"""Configure pytest options."""
16+
warnings_lines = r"""
17+
error::
18+
"""
19+
for warning_line in warnings_lines.split("\n"):
20+
warning_line = warning_line.strip()
21+
if warning_line and not warning_line.startswith("#"):
22+
config.addinivalue_line("filterwarnings", warning_line)
23+
24+
25+
"""
26+
The following fetch_file and configuration test module was taken from phys2bids.
27+
Credit to the original author(s) and to the phys2bids community.
28+
"""
1129

1230

1331
def fetch_file(osf_id, path, filename):
@@ -48,37 +66,37 @@ def fetch_file(osf_id, path, filename):
4866
return full_path
4967

5068

51-
@pytest.fixture(scope="session")
69+
@fixture(scope="session")
5270
def testdir(tmp_path_factory):
5371
"""Test path that will be used to download all files."""
5472
return tmp_path_factory.getbasetemp()
5573

5674

57-
@pytest.fixture
75+
@fixture(scope="function")
5876
def atlas(testdir):
5977
return fetch_file("h6nj7", testdir, "atlas.nii.gz")
6078

6179

62-
@pytest.fixture
80+
@fixture(scope="function")
6381
def atlastime(testdir):
6482
return fetch_file("ts6a8", testdir, "ats.nii.gz")
6583

6684

67-
@pytest.fixture
85+
@fixture(scope="function")
6886
def mean_fc(testdir):
6987
return fetch_file("jrg8d", testdir, "mean_fc_matlab.tsv")
7088

7189

72-
@pytest.fixture
90+
@fixture(scope="function")
7391
def sdi(testdir):
7492
return fetch_file("rs4dn", testdir, "SDI_matlab.tsv")
7593

7694

77-
@pytest.fixture
95+
@fixture(scope="function")
7896
def sc_mtx(testdir):
7997
return fetch_file("vwh75", testdir, "sc.mat")
8098

8199

82-
@pytest.fixture
100+
@fixture(scope="function")
83101
def timeseries(testdir):
84102
return fetch_file("ay8df", testdir, "func.mat")

nigsp/io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import numpy as np
2828

29-
from nigsp.utils import change_var_type
29+
from .utils import change_var_type
3030

3131
EXT_1D = [".txt", ".csv", ".tsv", ".1d", ".par", ".tsv.gz", ".csv.gz"]
3232
EXT_MAT = [".mat"]

nigsp/objects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import logging
1818
from copy import deepcopy
1919

20-
from nigsp import operations
20+
from . import operations
2121

2222
LGR = logging.getLogger(__name__)
2323

0 commit comments

Comments
 (0)