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

Fix pSTIR python tests #1276

Merged
merged 3 commits into from
Jul 8, 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
2 changes: 1 addition & 1 deletion src/common/Utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ def is_operator_adjoint(operator, num_tests=5, max_err=10e-5, verbose=True):
return True


def test_data_container_algebra(test, x, eps=1e-5):
def data_container_algebra_tests(test, x, eps=1e-5):

ax = x.as_array()
ay = numpy.ones_like(ax)
Expand Down
2 changes: 1 addition & 1 deletion src/xSTIR/pSTIR/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#=========================================================================

add_test(NAME PET_TESTS_PYTHON
COMMAND ${Python_EXECUTABLE} -m pytest --cov=sirf.STIR --cov-config=.coveragerc-STIR src/xSTIR/pSTIR
COMMAND ${Python_EXECUTABLE} -m pytest --cov=sirf.STIR --cov-config=.coveragerc-STIR src/xSTIR/pSTIR/tests
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
#add_test(NAME PET_DEMOS_PYTHON
# COMMAND ${PYTHON_EXECUTABLE} run_all.py --non-interactive
Expand Down
4 changes: 2 additions & 2 deletions src/xSTIR/pSTIR/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from sirf.Utilities import __licence__, RE_PYEXT
from glob import glob
from os import path
__version__ = "0.2.0"
__version__ = "0.2.1"
__author__ = "Casper da Costa-Luis"


Expand All @@ -32,7 +32,7 @@
failed = 0
ntests = 0

for script in sorted(glob('*.py')):
for script in sorted(glob('tests_*.py')):
if path.abspath(__file__) == path.abspath(script):
continue
print('\n\n--- running %s' % script)
Expand Down
6 changes: 3 additions & 3 deletions src/xSTIR/pSTIR/tests/tests_data_container_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""
from sirf.STIR import *
from sirf.Utilities import runner, RE_PYEXT, __license__
from sirf.Utilities import test_data_container_algebra
from sirf.Utilities import data_container_algebra_tests

__version__ = "0.2.3"
__author__ = "Evgueni Ovtchinnikov"
Expand All @@ -33,14 +33,14 @@ def test_main(rec=False, verb=False, throw=True):
AcquisitionData.set_storage_scheme(scheme)
raw_data_file = existing_filepath(data_path, 'Utahscat600k_ca_seg4.hs')
ad = AcquisitionData(raw_data_file)
test_data_container_algebra(test, ad)
data_container_algebra_tests(test, ad)

image_size = (31, 111, 111)
voxel_size = (3.375, 3, 3)
image = ImageData()
image.initialise(image_size, voxel_size)
image.fill(1.0)
test_data_container_algebra(test, image)
data_container_algebra_tests(test, image)

return test.failed, test.ntest

Expand Down
4 changes: 2 additions & 2 deletions src/xSTIR/pSTIR/tests/tests_qp_lc_rdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
__author__ = "Imraj Singh, Evgueni Ovtchinnikov, Kris Thielemans"


def test_Hessian(test, prior, x, eps=1e-3):
def Hessian_test(test, prior, x, eps=1e-3):
"""Checks that grad(x + dx) - grad(x) is close to H(x)*dx
"""
if x.norm() > 0:
Expand Down Expand Up @@ -84,7 +84,7 @@ def test_main(rec=False, verb=False, throw=True):

if isinstance(prior, sirf.STIR.RelativeDifferencePrior):
prior.set_epsilon(im.max()*.01)
test_Hessian(test, prior, im, 0.03)
Hessian_test(test, prior, im, 0.03)

return test.failed, test.ntest

Expand Down
2 changes: 1 addition & 1 deletion src/xSTIR/pSTIR/tests/tests_two.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_main(rec=False, verb=False, throw=True):
test.check(acq_data.norm())

image = acq_data.create_uniform_image(1.0)
test.check(image.norm())
test.check_if_equal_within_tolerance(image.norm(), numpy.sqrt(numpy.prod(image.dimensions())))

acq_model = AcquisitionModelUsingRayTracingMatrix()
acq_model.set_up(acq_data, image)
Expand Down
2 changes: 0 additions & 2 deletions src/xSTIR/pSTIR/tests/tests_two.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
4.932500e+04
7.182416e+02
2.256327e+02
4.932500e+04
7.182416e+02
2.256327e+02
Loading