summaryrefslogtreecommitdiffstats
path: root/Wrappers
diff options
context:
space:
mode:
Diffstat (limited to 'Wrappers')
-rw-r--r--Wrappers/Python/ccpi/framework/framework.py10
-rwxr-xr-xWrappers/Python/test/test_DataContainer.py19
2 files changed, 27 insertions, 2 deletions
diff --git a/Wrappers/Python/ccpi/framework/framework.py b/Wrappers/Python/ccpi/framework/framework.py
index 968c69c..65121d2 100644
--- a/Wrappers/Python/ccpi/framework/framework.py
+++ b/Wrappers/Python/ccpi/framework/framework.py
@@ -939,6 +939,7 @@ class DataContainer(object):
def log(self, *args, **kwargs):
'''Applies log pixel-wise to the DataContainer'''
return self.pixel_wise_unary(numpy.log, *args, **kwargs)
+
#def __abs__(self):
# operation = FM.OPERATION.ABS
# return self.callFieldMath(operation, None, self.mask, self.maskOnValue)
@@ -981,7 +982,14 @@ class DataContainer(object):
return sf
else:
raise ValueError('Shapes are not aligned: {} != {}'.format(self.shape, other.shape))
-
+
+ def min(self, *args, **kwargs):
+ '''Returns the min pixel value in the DataContainer'''
+ return numpy.min(self.as_array(), *args, **kwargs)
+
+ def max(self, *args, **kwargs):
+ '''Returns the max pixel value in the DataContainer'''
+ return numpy.max(self.as_array(), *args, **kwargs)
diff --git a/Wrappers/Python/test/test_DataContainer.py b/Wrappers/Python/test/test_DataContainer.py
index d2d5b05..6e297ee 100755
--- a/Wrappers/Python/test/test_DataContainer.py
+++ b/Wrappers/Python/test/test_DataContainer.py
@@ -744,7 +744,24 @@ class TestDataContainer(unittest.TestCase):
res = numpy.ones_like(d1.as_array()) * 4.
numpy.testing.assert_array_equal(res, out.as_array())
-
+ def test_min(self):
+ print ("test min")
+ ig = ImageGeometry(10,10)
+ a = numpy.asarray(numpy.linspace(-10,10, num=100, endpoint=True), dtype=numpy.float32)
+ a = a.reshape((10,10))
+ d1 = ig.allocate(1)
+ d1.fill(a)
+ self.assertAlmostEqual(d1.min(), -10.)
+
+ def test_max(self):
+ print ("test max")
+ ig = ImageGeometry(10,10)
+ a = numpy.asarray(numpy.linspace(-10,10, num=100, endpoint=True), dtype=numpy.float32)
+ a = a.reshape((10,10))
+ d1 = ig.allocate(1)
+ d1.fill(a)
+ self.assertAlmostEqual(d1.max(), 10.)
+