Skip to content

Commit d6170fb

Browse files
authored
Merge pull request #210 from effigies/fix/tests-py312-np2
TEST: Fix tests for Python 3.12, numpy 2.0, and pytest-xdist
2 parents 76832f5 + 4d2f4c7 commit d6170fb

File tree

6 files changed

+20
-8
lines changed

6 files changed

+20
-8
lines changed

.github/workflows/pythonpackage.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
python-version: ['3.8', '3.9', '3.10', '3.11']
19+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
2020

2121
steps:
2222
- name: Set up Python ${{ matrix.python-version }}
@@ -91,8 +91,6 @@ jobs:
9191
runs-on: ubuntu-latest
9292
steps:
9393
- uses: actions/checkout@v3
94-
- name: Set up Python 3.7
94+
- name: Set up Python 3
9595
uses: actions/setup-python@v4
96-
with:
97-
python-version: 3.7
9896
- run: pipx run flake8 nitransforms

nitransforms/io/afni.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def _is_oblique(affine, thres=OBLIQUITY_THRESHOLD_DEG):
237237
True
238238
239239
"""
240-
return (obliquity(affine).max() * 180 / pi) > thres
240+
return float(obliquity(affine).max() * 180 / pi) > thres
241241

242242

243243
def _afni_deobliqued_grid(oblique, shape):

nitransforms/io/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ class LinearParameters(LinearTransformStruct):
7676
Examples
7777
--------
7878
>>> lp = LinearParameters()
79-
>>> np.all(lp.structarr['parameters'] == np.eye(4))
79+
>>> np.array_equal(lp.structarr['parameters'], np.eye(4))
8080
True
8181
8282
>>> p = np.diag([2., 2., 2., 1.])
8383
>>> lp = LinearParameters(p)
84-
>>> np.all(lp.structarr['parameters'] == p)
84+
>>> np.array_equal(lp.structarr['parameters'], p)
8585
True
8686
8787
"""

nitransforms/tests/test_cli.py

+8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
import os
12
from textwrap import dedent
23

34
import pytest
45

56
from ..cli import cli_apply, main as ntcli
67

8+
if os.getenv("PYTEST_XDIST_WORKER"):
9+
breaks_on_xdist = pytest.mark.skip(reason="xdist is active; rerun without to run this test.")
10+
else:
11+
def breaks_on_xdist(test):
12+
return test
713

14+
15+
@breaks_on_xdist
816
def test_cli(capsys):
917
# empty command
1018
with pytest.raises(SystemExit):

nitransforms/tests/test_version.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
"""Test _version.py."""
22
import sys
33
from collections import namedtuple
4-
from pkg_resources import DistributionNotFound
54
from importlib import reload
5+
import pytest
66
import nitransforms
77

8+
try:
9+
from pkg_resources import DistributionNotFound
10+
except ImportError:
11+
pytest.skip(allow_module_level=True)
12+
813

914
def test_version_scm0(monkeypatch):
1015
"""Retrieve the version via setuptools_scm."""

setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ test =
4949
pytest-cov
5050
pytest-env
5151
codecov
52+
lxml
5253
tests =
5354
%(test)s
5455

0 commit comments

Comments
 (0)