Skip to content

Commit

Permalink
Merge pull request #1276 from KrisThielemans/fix_Python_tests
Browse files Browse the repository at this point in the history
Fix pSTIR python tests
  • Loading branch information
KrisThielemans authored Jul 8, 2024
2 parents 44ed358 + 3a05f06 commit 6c10a0d
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 12 deletions.
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

0 comments on commit 6c10a0d

Please sign in to comment.