Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEST: Fix tests for Python 3.12, numpy 2.0, and pytest-xdist #210

Merged
merged 3 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading