Skip to content

Commit

Permalink
Add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bwohlberg committed Nov 3, 2024
1 parent 9fced0b commit 227ce0e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions scico/test/linop/xray/test_astra.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,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)
Expand Down Expand Up @@ -290,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, 0.0], [1.0, 1.0, 0.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)

0 comments on commit 227ce0e

Please sign in to comment.