Skip to content

Commit

Permalink
let pytest find all pSTIR tests
Browse files Browse the repository at this point in the history
Had to rename 2 functions from test_* to *_tests to avoid
pytest flagging up an error
  • Loading branch information
KrisThielemans committed Jul 8, 2024
1 parent d3cb586 commit ccd132f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 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
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

0 comments on commit ccd132f

Please sign in to comment.