From c3390b068f09ad64d4cfed7de1cb162e646be766 Mon Sep 17 00:00:00 2001 From: Mian Asbat Ahmad Date: Thu, 28 Feb 2019 14:18:46 +0000 Subject: [PATCH] Issue #14: Test case added, imports corrected Test case added to check function with empty data. --- sksurgerycore/algorithms/errors.py | 4 ++-- sksurgerycore/algorithms/procrustes.py | 4 ++-- tests/algorithms/test_errors.py | 8 +++++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/sksurgerycore/algorithms/errors.py b/sksurgerycore/algorithms/errors.py index 7d23b56..4834b30 100644 --- a/sksurgerycore/algorithms/errors.py +++ b/sksurgerycore/algorithms/errors.py @@ -3,7 +3,7 @@ """Functions for point based registration using Orthogonal Procrustes.""" import numpy as np -from sksurgerycore.algorithms.procrustes import validate_procrustes_inputs +import sksurgerycore.algorithms.procrustes as p def compute_fre(fixed, moving, rotation, translation): @@ -19,7 +19,7 @@ def compute_fre(fixed, moving, rotation, translation): """ # pylint: disable=assignment-from-no-return - validate_procrustes_inputs(fixed, moving) + p.validate_procrustes_inputs(fixed, moving) transformed_moving = np.matmul(rotation, moving.transpose()) + translation squared_error_elementwise = np.square(fixed diff --git a/sksurgerycore/algorithms/procrustes.py b/sksurgerycore/algorithms/procrustes.py index d638bd8..06c2200 100644 --- a/sksurgerycore/algorithms/procrustes.py +++ b/sksurgerycore/algorithms/procrustes.py @@ -3,7 +3,7 @@ """Functions for point based registration using Orthogonal Procrustes.""" import numpy as np -from sksurgerycore.algorithms.errors import compute_fre +import sksurgerycore.algorithms.errors as e def validate_procrustes_inputs(fixed, moving): @@ -116,6 +116,6 @@ def orthogonal_procrustes(fixed, moving): T[0][0] = tmp[0] T[1][0] = tmp[1] T[2][0] = tmp[2] - fre = compute_fre(fixed, moving, R, T) + fre = e.compute_fre(fixed, moving, R, T) return R, T, fre diff --git a/tests/algorithms/test_errors.py b/tests/algorithms/test_errors.py index 77f5c74..23ecae0 100644 --- a/tests/algorithms/test_errors.py +++ b/tests/algorithms/test_errors.py @@ -3,6 +3,12 @@ import six import numpy as np import pytest -import sksurgerycore.algorithms.procrustes as p +import sksurgerycore.algorithms.errors as e + + +def test_empty_fixed(): + + with pytest.raises(TypeError): + e.compute_fre(None, None, np.ones(1, 3), np.ones(3, 3)) -- 2.24.1