summaryrefslogtreecommitdiffstats
path: root/Wrappers
diff options
context:
space:
mode:
authorEdoardo Pasca <edo.paskino@gmail.com>2019-06-21 11:02:05 +0100
committerEdoardo Pasca <edo.paskino@gmail.com>2019-06-21 11:02:33 +0100
commita12ba71294078c9d1512d926296eca70b3349725 (patch)
tree33d804444bff62833cea6269615138ec9086b3fc /Wrappers
parentb3100c1af0222e7cfaac4dff93111e3bd0331649 (diff)
downloadframework-a12ba71294078c9d1512d926296eca70b3349725.tar.gz
framework-a12ba71294078c9d1512d926296eca70b3349725.tar.bz2
framework-a12ba71294078c9d1512d926296eca70b3349725.tar.xz
framework-a12ba71294078c9d1512d926296eca70b3349725.zip
added testclass file to hold the CCPiTestClass definitions
Diffstat (limited to 'Wrappers')
-rwxr-xr-xWrappers/Python/test/testclass.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/Wrappers/Python/test/testclass.py b/Wrappers/Python/test/testclass.py
new file mode 100755
index 0000000..51b9f3f
--- /dev/null
+++ b/Wrappers/Python/test/testclass.py
@@ -0,0 +1,41 @@
+import unittest
+from ccpi.framework import ImageGeometry, ImageData, BlockDataContainer, DataContainer
+import numpy
+
+def dt(steps):
+ return steps[-1] - steps[-2]
+
+class CCPiTestClass(unittest.TestCase):
+ def assertBlockDataContainerEqual(self, container1, container2):
+ print ("assert Block Data Container Equal")
+ self.assertTrue(issubclass(container1.__class__, container2.__class__))
+ for col in range(container1.shape[0]):
+ if issubclass(container1.get_item(col).__class__, DataContainer):
+ print ("Checking col ", col)
+ self.assertNumpyArrayEqual(
+ container1.get_item(col).as_array(),
+ container2.get_item(col).as_array()
+ )
+ else:
+ self.assertBlockDataContainerEqual(container1.get_item(col),container2.get_item(col))
+
+ def assertNumpyArrayEqual(self, first, second):
+ res = True
+ try:
+ numpy.testing.assert_array_equal(first, second)
+ except AssertionError as err:
+ res = False
+ print(err)
+ self.assertTrue(res)
+
+ def assertNumpyArrayAlmostEqual(self, first, second, decimal=6):
+ res = True
+ try:
+ numpy.testing.assert_array_almost_equal(first, second, decimal)
+ except AssertionError as err:
+ res = False
+ print(err)
+ print("expected " , second)
+ print("actual " , first)
+
+ self.assertTrue(res) \ No newline at end of file