From 4e2abf0f86e4f8b25202f0931e7b811a0c03725b Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Sat, 22 Jun 2024 10:31:20 +0900 Subject: [PATCH 1/3] TEST: Fix tests for PY312, NP2 --- nitransforms/io/afni.py | 2 +- nitransforms/io/base.py | 4 ++-- nitransforms/tests/test_version.py | 7 ++++++- setup.cfg | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/nitransforms/io/afni.py b/nitransforms/io/afni.py index 06eaf432..7c66d434 100644 --- a/nitransforms/io/afni.py +++ b/nitransforms/io/afni.py @@ -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): diff --git a/nitransforms/io/base.py b/nitransforms/io/base.py index d86c8539..3c923426 100644 --- a/nitransforms/io/base.py +++ b/nitransforms/io/base.py @@ -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 """ diff --git a/nitransforms/tests/test_version.py b/nitransforms/tests/test_version.py index a0723e9a..bc4c4a0a 100644 --- a/nitransforms/tests/test_version.py +++ b/nitransforms/tests/test_version.py @@ -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.""" diff --git a/setup.cfg b/setup.cfg index 20fe531e..79e47f47 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,6 +49,7 @@ test = pytest-cov pytest-env codecov + lxml tests = %(test)s From 06f8a274a8c19ee7c0f058c4fa83ff8ef12584e3 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Sat, 22 Jun 2024 11:00:45 +0900 Subject: [PATCH 2/3] TEST: Disable test_cli if xdist is enabled --- nitransforms/tests/test_cli.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nitransforms/tests/test_cli.py b/nitransforms/tests/test_cli.py index 7f16a1de..58867131 100644 --- a/nitransforms/tests/test_cli.py +++ b/nitransforms/tests/test_cli.py @@ -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): From 4d2f4c7b7c0a5ace5ca5dae9ca774bda16b83379 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Sat, 22 Jun 2024 11:01:03 +0900 Subject: [PATCH 3/3] CI: Add Python 3.12 tests, unpin the flake8 Python version --- .github/workflows/pythonpackage.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 97c4984e..71a1494b 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -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 }} @@ -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