Commit c3390b06 authored by Mian Asbat Ahmad's avatar Mian Asbat Ahmad

Issue #14: Test case added, imports corrected

Test case added to check  function with empty data.
parent ab5215db
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"""Functions for point based registration using Orthogonal Procrustes.""" """Functions for point based registration using Orthogonal Procrustes."""
import numpy as np 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): def compute_fre(fixed, moving, rotation, translation):
...@@ -19,7 +19,7 @@ def compute_fre(fixed, moving, rotation, translation): ...@@ -19,7 +19,7 @@ def compute_fre(fixed, moving, rotation, translation):
""" """
# pylint: disable=assignment-from-no-return # 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 transformed_moving = np.matmul(rotation, moving.transpose()) + translation
squared_error_elementwise = np.square(fixed squared_error_elementwise = np.square(fixed
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
"""Functions for point based registration using Orthogonal Procrustes.""" """Functions for point based registration using Orthogonal Procrustes."""
import numpy as np import numpy as np
from sksurgerycore.algorithms.errors import compute_fre import sksurgerycore.algorithms.errors as e
def validate_procrustes_inputs(fixed, moving): def validate_procrustes_inputs(fixed, moving):
...@@ -116,6 +116,6 @@ def orthogonal_procrustes(fixed, moving): ...@@ -116,6 +116,6 @@ def orthogonal_procrustes(fixed, moving):
T[0][0] = tmp[0] T[0][0] = tmp[0]
T[1][0] = tmp[1] T[1][0] = tmp[1]
T[2][0] = tmp[2] T[2][0] = tmp[2]
fre = compute_fre(fixed, moving, R, T) fre = e.compute_fre(fixed, moving, R, T)
return R, T, fre return R, T, fre
...@@ -3,6 +3,12 @@ ...@@ -3,6 +3,12 @@
import six import six
import numpy as np import numpy as np
import pytest 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))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment