From cb8e73f20ce9e2e17a033f2da0fc593a4f4f3b0e Mon Sep 17 00:00:00 2001 From: Stephan Seitz <stephan.seitz@fau.de> Date: Wed, 26 Feb 2020 15:44:02 +0100 Subject: [PATCH] Make test runnable without pyconrad --- setup.cfg | 8 ++++---- setup.py | 2 -- tests/test_projection.py | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/setup.cfg b/setup.cfg index 16fedb7..4ccfa57 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,10 +4,10 @@ [metadata] name = pyronn-torch -description = Add a short description here! -author = Stephan Seitz -author-email = stephan.seitz@fau.de -license = mit +description = PyTorch bindings for PYRO-NN (https://github.com/csyben/PYRO-NN) +author = Stephan Seitz, Christopher Symben +author-email = stephan.seitz@fau.de, christopher.syben@fau.de +license = GPLv3 long-description = file: README.rst long-description-content-type = text/x-rst; charset=UTF-8 url = https://github.com/pyscaffold/pyscaffold/ diff --git a/setup.py b/setup.py index a46182b..5038bb1 100644 --- a/setup.py +++ b/setup.py @@ -41,8 +41,6 @@ if __name__ == "__main__": [generated_file] + cuda_sources, extra_compile_args={'cxx': ['--std=c++14'], 'nvcc': ['-arch=sm_35']}) - - ], cmdclass={ 'build_ext': BuildExtension diff --git a/tests/test_projection.py b/tests/test_projection.py index 679553c..f72f3cc 100644 --- a/tests/test_projection.py +++ b/tests/test_projection.py @@ -6,6 +6,9 @@ """ """ +import os + +import numpy as np import pytest import pyronn_torch @@ -18,6 +21,41 @@ def test_init(): @pytest.mark.parametrize('with_texture', ('with_texture', False)) @pytest.mark.parametrize('with_backward', ('with_backward', False)) def test_projection(with_texture, with_backward): + projector = pyronn_torch.ConeBeamProjector( + (128, 128, 128), + (2.0, 2.0, 2.0), + (-127.5, -127.5, -127.5), + (2, 480, 620), + [1.0, 1.0], + (0, 0), + np.array([[[-3.10e+2, -1.20e+03, 0.00e+00, 1.86e+5], + [-2.40e+2, 0.00e+00, 1.20e+03, 1.44e+5], + [-1.00e+00, 0.00e+00, 0.00e+00, 6.00e+2]], + [[-2.89009888e+2, -1.20522754e+3, -1.02473585e-13, + 1.86000000e+5], + [-2.39963440e+2, -4.18857765e+0, 1.20000000e+3, + 1.44000000e+5], + [-9.99847710e-01, -1.74524058e-2, 0.00000000e+0, + 6.00000000e+2]]]) + ) + + volume = projector.new_volume_tensor(requires_grad=True if with_backward else False) + + volume += 1. + result = projector.project_forward(volume, use_texture=with_texture) + + assert result is not None + if with_backward: + assert volume.requires_grad + assert result.requires_grad + + loss = result.mean() + loss.backward() + + +@pytest.mark.skipif('CI' in os.environ, reason="No conrad config on CI") +@pytest.mark.parametrize('with_backward', ('with_backward', False)) +def test_conrad_config(with_backward, with_texture=True): projector = pyronn_torch.ConeBeamProjector.from_conrad_config() volume = projector.new_volume_tensor(requires_grad=True if with_backward else False) -- GitLab