From e965283a60c03c3215a3f7037920b5b67bf371ce Mon Sep 17 00:00:00 2001 From: jack-parsons <jack.parsons.uk@icloud.com> Date: Thu, 25 Jul 2019 16:21:51 +0100 Subject: [PATCH] Cleaning up registration doctests and adding unittests for registration module --- AmpScan/registration.py | 16 +++++++++------- tests/test_registration.py | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 tests/test_registration.py diff --git a/AmpScan/registration.py b/AmpScan/registration.py index b09c12a..3bc598b 100644 --- a/AmpScan/registration.py +++ b/AmpScan/registration.py @@ -9,6 +9,11 @@ from scipy import spatial from AmpScan.core import AmpObject import matplotlib.pyplot as plt +# For the doc examples +import os +basefh = os.getcwd()+"\\tests\\stl_file.stl" +targfh = os.getcwd()+"\\tests\\stl_file_2.stl" + class registration(object): r""" Registration methods between two AmpObject meshes. This function morphs the baseline @@ -36,13 +41,10 @@ class registration(object): Examples -------- - >>> import os - >>> import AmpScan - >>> basefh = os.getcwd()+"\\tests\\stl_file.stl" - >>> targfh = os.getcwd()+"\\tests\\stl_file_2.stl" - >>> baseline = AmpScan.AmpObject(basefh) - >>> target = AmpScan.AmpObject(targfh) - >>> reg = AmpScan.registration(baseline, target, steps=10, neigh=10, smooth=1).reg + >>> from AmpScan.core import AmpObject + >>> baseline = AmpObject(basefh) + >>> target = AmpObject(targfh) + >>> reg = registration(baseline, target, steps=10, neigh=10, smooth=1).reg """ def __init__(self, baseline, target, method='point2plane', *args, **kwargs): diff --git a/tests/test_registration.py b/tests/test_registration.py new file mode 100644 index 0000000..6a81ae2 --- /dev/null +++ b/tests/test_registration.py @@ -0,0 +1,21 @@ +""" +Testing suite for the core module +""" + +import unittest +import os +import numpy as np +from random import randrange + + +class TestCore(unittest.TestCase): + ACCURACY = 5 # The number of decimal places to value accuracy for - needed due to floating point inaccuracies + + def setUp(self): + """Runs before each unit test. + Sets up the AmpObject object using "sample_stl_sphere_BIN.stl". + """ + from AmpScan.core import AmpObject + stl_path = self.get_path("sample_stl_sphere_BIN.stl") + self.amp = AmpObject(stl_path) + -- GitLab