Skip to content

Commit

Permalink
Merge pull request #210 from effigies/fix/tests-py312-np2
Browse files Browse the repository at this point in the history
TEST: Fix tests for Python 3.12, numpy 2.0, and pytest-xdist
  • Loading branch information
effigies authored Jun 22, 2024
2 parents 76832f5 + 4d2f4c7 commit d6170fb
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -91,8 +91,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.7
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: 3.7
- run: pipx run flake8 nitransforms
2 changes: 1 addition & 1 deletion nitransforms/io/afni.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def _is_oblique(affine, thres=OBLIQUITY_THRESHOLD_DEG):
True
"""
return (obliquity(affine).max() * 180 / pi) > thres
return float(obliquity(affine).max() * 180 / pi) > thres


def _afni_deobliqued_grid(oblique, shape):
Expand Down
4 changes: 2 additions & 2 deletions nitransforms/io/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ class LinearParameters(LinearTransformStruct):
Examples
--------
>>> lp = LinearParameters()
>>> np.all(lp.structarr['parameters'] == np.eye(4))
>>> np.array_equal(lp.structarr['parameters'], np.eye(4))
True
>>> p = np.diag([2., 2., 2., 1.])
>>> lp = LinearParameters(p)
>>> np.all(lp.structarr['parameters'] == p)
>>> np.array_equal(lp.structarr['parameters'], p)
True
"""
Expand Down
8 changes: 8 additions & 0 deletions nitransforms/tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import os
from textwrap import dedent

import pytest

from ..cli import cli_apply, main as ntcli

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


@breaks_on_xdist
def test_cli(capsys):
# empty command
with pytest.raises(SystemExit):
Expand Down
7 changes: 6 additions & 1 deletion nitransforms/tests/test_version.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
"""Test _version.py."""
import sys
from collections import namedtuple
from pkg_resources import DistributionNotFound
from importlib import reload
import pytest
import nitransforms

try:
from pkg_resources import DistributionNotFound
except ImportError:
pytest.skip(allow_module_level=True)


def test_version_scm0(monkeypatch):
"""Retrieve the version via setuptools_scm."""
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ test =
pytest-cov
pytest-env
codecov
lxml
tests =
%(test)s

Expand Down

0 comments on commit d6170fb

Please sign in to comment.