diff options
Diffstat (limited to 'Wrappers/Python')
-rwxr-xr-x | Wrappers/Python/ccpi/framework/framework.py | 19 | ||||
-rwxr-xr-x | Wrappers/Python/test/test_DataContainer.py | 13 |
2 files changed, 32 insertions, 0 deletions
diff --git a/Wrappers/Python/ccpi/framework/framework.py b/Wrappers/Python/ccpi/framework/framework.py index 7afd2c1..98e9a8c 100755 --- a/Wrappers/Python/ccpi/framework/framework.py +++ b/Wrappers/Python/ccpi/framework/framework.py @@ -175,6 +175,15 @@ class ImageGeometry(object): #def shape(self): # '''Returns the shape of the array of the ImageData it describes''' # return self.shape + def __eq__(self, other): + '''Returns whether two geometries are equal''' + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + else: + return False + + def __ne__(self, other): + return not self.__eq__(other) class AcquisitionGeometry(object): RANDOM = 'random' @@ -309,6 +318,16 @@ class AcquisitionGeometry(object): if dimension_labels != self.dimension_labels: return out.subset(dimensions=dimension_labels) return out + def __eq__(self, other): + '''Returns whether two geometries are equal''' + if isinstance(other, self.__class__): + return self.__dict__ == other.__dict__ + else: + return False + + def __ne__(self, other): + return not self.__eq__(other) + class DataContainer(object): '''Generic class to hold data diff --git a/Wrappers/Python/test/test_DataContainer.py b/Wrappers/Python/test/test_DataContainer.py index 7a7e6a0..cb09a1f 100755 --- a/Wrappers/Python/test/test_DataContainer.py +++ b/Wrappers/Python/test/test_DataContainer.py @@ -494,6 +494,8 @@ class TestDataContainer(unittest.TestCase): self.assertEqual(order[0], image.dimension_labels[0]) self.assertEqual(order[1], image.dimension_labels[1]) self.assertEqual(order[2], image.dimension_labels[2]) + + #vgeometry.allocate('') def test_AcquisitionGeometry_allocate(self): ageometry = AcquisitionGeometry(dimension=2, angles=numpy.linspace(0, 180, num=10), @@ -523,6 +525,17 @@ class TestDataContainer(unittest.TestCase): self.assertEqual(order[1], sino.dimension_labels[1]) self.assertEqual(order[2], sino.dimension_labels[2]) self.assertEqual(order[2], sino.dimension_labels[2]) + + def test_ImageGeometry_equal(self): + vg1 = ImageGeometry(voxel_num_x=4, voxel_num_y=3, channels=2) + vg2 = ImageGeometry(voxel_num_x=4, voxel_num_y=3, channels=2) + self.assertTrue(vg1 == vg2) + self.assertFalse(vg1 != vg2) + + vg2 = ImageGeometry(voxel_num_z=3,voxel_num_x=4, voxel_num_y=3, channels=2) + self.assertTrue(vg1 != vg2) + self.assertFalse(vg1 == vg2) + def assertNumpyArrayEqual(self, first, second): res = True |