Skip to content
Snippets Groups Projects
Commit 09df22ef authored by Joshua Steer's avatar Joshua Steer
Browse files

Merge branch 'master' of https://git.soton.ac.uk/js22g12/AmpScan

parents b24c9690 d91a4d5a
No related branches found
No related tags found
No related merge requests found
Pipeline #359 passed
...@@ -341,7 +341,7 @@ class AmpObject(trimMixin, smoothMixin, analyseMixin, visMixin): ...@@ -341,7 +341,7 @@ class AmpObject(trimMixin, smoothMixin, analyseMixin, visMixin):
>>> ang = [np.pi/2, -np.pi/4, np.pi/3] >>> ang = [np.pi/2, -np.pi/4, np.pi/3]
>>> amp.rotateAng(ang, ang='rad') >>> amp.rotateAng(ang, ang='rad')
""" """
if type(rot)==type([]): if isinstance(rot, (tuple, list, np.ndarray)):
R = self.rotMatrix(rot, ang) R = self.rotMatrix(rot, ang)
self.rotate(R, norms) self.rotate(R, norms)
else: else:
......
...@@ -30,6 +30,7 @@ class trimMixin(object): ...@@ -30,6 +30,7 @@ class trimMixin(object):
>>> amp.planarTrim(100, 2) >>> amp.planarTrim(100, 2)
""" """
if type(height)==float:
# planar values for each vert on face # planar values for each vert on face
fv = self.vert[self.faces, plane] fv = self.vert[self.faces, plane]
# Number points on each face are above cut plane # Number points on each face are above cut plane
...@@ -49,3 +50,5 @@ class trimMixin(object): ...@@ -49,3 +50,5 @@ class trimMixin(object):
self.faces = vInd[self.faces] self.faces = vInd[self.faces]
self.vert = self.vert[~delv, :] self.vert = self.vert[~delv, :]
self.calcStruct() self.calcStruct()
else:
raise TypeError("height arg must be a float")
\ No newline at end of file
...@@ -4,13 +4,15 @@ import sys ...@@ -4,13 +4,15 @@ import sys
class TestBasicFunction(unittest.TestCase): class TestBasicFunction(unittest.TestCase):
def SetUp(self):
modPath = os.path.abspath(os.getcwd())
sys.path.insert(0, modPath)
def test_running(self): def test_running(self):
print("Running sample_test.py") print("Running sample_test.py")
self.assertTrue(True) self.assertTrue(True)
def test_python_imports(self): def test_python_imports(self):
modPath = os.path.abspath(os.getcwd())
sys.path.insert(0, modPath)
import numpy, scipy, matplotlib, vtk, AmpScan.core import numpy, scipy, matplotlib, vtk, AmpScan.core
s = str(type(numpy)) s = str(type(numpy))
self.assertEqual(s, "<class 'module'>") self.assertEqual(s, "<class 'module'>")
...@@ -28,9 +30,7 @@ class TestBasicFunction(unittest.TestCase): ...@@ -28,9 +30,7 @@ class TestBasicFunction(unittest.TestCase):
s = str(type("string")) s = str(type("string"))
self.assertEqual(s, "<class 'module'>") self.assertEqual(s, "<class 'module'>")
def test_import_stl(self): def test_rotate(self):
modPath = os.path.abspath(os.getcwd())
sys.path.insert(0, modPath)
stlPath = os.path.abspath(os.getcwd()) + "\\tests\\sample_stl_sphere_BIN.stl" stlPath = os.path.abspath(os.getcwd()) + "\\tests\\sample_stl_sphere_BIN.stl"
from AmpScan.core import AmpObject from AmpScan.core import AmpObject
Amp = AmpObject(stlPath) Amp = AmpObject(stlPath)
...@@ -40,5 +40,14 @@ class TestBasicFunction(unittest.TestCase): ...@@ -40,5 +40,14 @@ class TestBasicFunction(unittest.TestCase):
Amp.rotateAng(7) Amp.rotateAng(7)
Amp.rotateAng({}) Amp.rotateAng({})
def test_trim(self):
# a new test for the trim module
stlPath = os.path.abspath(os.getcwd()) + "\\tests\\sample_stl_sphere_BIN.stl"
from AmpScan.core import AmpObject
Amp = AmpObject(stlPath)
#with self.assertRaises(TypeError):
#Amp.planarTrim([], plane=[])
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment