diff --git a/.github/workflows/check_files.yml b/.github/workflows/check_files.yml index 7fee7c27..5346fcce 100644 --- a/.github/workflows/check_files.yml +++ b/.github/workflows/check_files.yml @@ -11,7 +11,7 @@ jobs: - name: checkout uses: actions/checkout@v4 - id: files - uses: Ana06/get-changed-files@v2.2.0 + uses: Ana06/get-changed-files@v2.3.0 continue-on-error: true - run: | for f in ${{ steps.files.outputs.added }}; do diff --git a/.github/workflows/pytest_ubuntu.yml b/.github/workflows/pytest_ubuntu.yml index 67b50617..2acf3a1b 100644 --- a/.github/workflows/pytest_ubuntu.yml +++ b/.github/workflows/pytest_ubuntu.yml @@ -113,7 +113,9 @@ jobs: coverage combine coverage?/.coverage coverage report coverage xml - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} with: env_vars: OS,PYTHON fail_ci_if_error: false diff --git a/scico/linop/xray/astra.py b/scico/linop/xray/astra.py index b5cf542c..ab16dc7e 100644 --- a/scico/linop/xray/astra.py +++ b/scico/linop/xray/astra.py @@ -141,7 +141,7 @@ def volume_coords_to_world_coords(idx: np.ndarray, vol_geom: VolumeGeometry) -> def _volume_index_to_astra_world_2d(idx: np.ndarray, vol_geom: VolumeGeometry) -> np.ndarray: """Convert a 2D volume coordinate into a 2D world coordinate.""" - coord = idx[..., [2, 1]] # x:col, y:row, + coord = idx[..., [1, 0]] # x:col, y:row, nx = np.array( # (x, y) order ( vol_geom["GridColCount"], diff --git a/scico/test/linop/test_convolve.py b/scico/test/linop/test_convolve.py index 31714a9a..5eea9fd7 100644 --- a/scico/test/linop/test_convolve.py +++ b/scico/test/linop/test_convolve.py @@ -76,6 +76,15 @@ def testobj(request): yield ConvolveTestObj() +def test_init(testobj): + with pytest.raises(ValueError): + A = Convolve(input_shape=(16, 16), h=testobj.psf_A) + with pytest.raises(ValueError): + A = Convolve(input_shape=(16,), h=testobj.psf_A, mode="invalid") + A = Convolve(input_shape=(16,), input_dtype=None, h=testobj.psf_A) + assert A.input_dtype == testobj.psf_A.dtype + + @pytest.mark.parametrize("operator", [op.mul, op.truediv]) def test_scalar_left(testobj, operator): A = operator(testobj.A, testobj.scalar) diff --git a/scico/test/linop/xray/test_astra.py b/scico/test/linop/xray/test_astra.py index c94314fd..f2cb156f 100644 --- a/scico/test/linop/xray/test_astra.py +++ b/scico/test/linop/xray/test_astra.py @@ -8,7 +8,6 @@ import scico.numpy as snp from scico.linop import DiagonalStack from scico.test.linop.test_linop import adjoint_test -from scico.test.linop.xray.test_svmbir import make_im try: from scico.linop.xray.astra import ( @@ -30,6 +29,17 @@ RTOL_GPU_RANDOM_INPUT = 1.0 +def make_im(Nx, Ny, is_3d=True): + x, y = snp.meshgrid(snp.linspace(-1, 1, Nx), snp.linspace(-1, 1, Ny), indexing="ij") + + im = snp.where((x - 0.25) ** 2 / 3 + y**2 < 0.1, 1.0, 0.0) + if is_3d: + im = im[snp.newaxis, :, :] + im = im.astype(snp.float32) + + return im + + def get_tol(): if jax.devices()[0].device_kind == "cpu": rtol = RTOL_CPU @@ -70,6 +80,31 @@ def testobj(request): yield XRayTransform2DTest(request.param) +def test_init(testobj): + with pytest.raises(ValueError): + A = XRayTransform2D( + input_shape=(16, 16, 16), + det_count=16, + det_spacing=1.0, + angles=np.linspace(0, np.pi, 32, False), + ) + with pytest.raises(ValueError): + A = XRayTransform2D( + input_shape=(16, 16), + det_count=16.3, + det_spacing=1.0, + angles=np.linspace(0, np.pi, 32, False), + ) + with pytest.raises(ValueError): + A = XRayTransform2D( + input_shape=(16, 16), + det_count=16, + det_spacing=1.0, + angles=np.linspace(0, np.pi, 32, False), + device="invalid", + ) + + def test_ATA_call(testobj): # Test for the call-based interface Ax = testobj.A(testobj.x) @@ -280,6 +315,13 @@ def test_convert_from_scico_geometry(test_geometry): np.testing.assert_allclose(vectors[0, 6:], proj_geom_truth["Vectors"][0, 6:]) +def test_vol_coord_to_world_coord(): + vol_geom = scico.linop.xray.astra.astra.create_vol_geom(16, 16) + vc = np.array([[0.0, 0.0], [1.0, 1.0]]) + wc = scico.linop.xray.astra.volume_coords_to_world_coords(vc, vol_geom) + assert wc.shape == (2, 2) + + def test_ensure_writeable(): assert isinstance(_ensure_writeable(np.ones((2, 1))), np.ndarray) assert isinstance(_ensure_writeable(snp.ones((2, 1))), np.ndarray) diff --git a/scico/test/linop/xray/test_svmbir.py b/scico/test/linop/xray/test_svmbir.py index 46077f3d..d4980470 100644 --- a/scico/test/linop/xray/test_svmbir.py +++ b/scico/test/linop/xray/test_svmbir.py @@ -60,7 +60,7 @@ def pytest_generate_tests(metafunc): def make_im(Nx, Ny, is_3d=True): - x, y = snp.meshgrid(snp.linspace(-1, 1, Nx), snp.linspace(-1, 1, Ny)) + x, y = snp.meshgrid(snp.linspace(-1, 1, Nx), snp.linspace(-1, 1, Ny), indexing="ij") im = snp.where((x - 0.25) ** 2 / 3 + y**2 < 0.1, 1.0, 0.0) if is_3d: