diff options
Diffstat (limited to 'Wrappers/Python')
-rwxr-xr-x | Wrappers/Python/ccpi/framework/framework.py | 8 | ||||
-rwxr-xr-x | Wrappers/Python/test/test_DataContainer.py | 11 |
2 files changed, 19 insertions, 0 deletions
diff --git a/Wrappers/Python/ccpi/framework/framework.py b/Wrappers/Python/ccpi/framework/framework.py index ed97862..c58088a 100755 --- a/Wrappers/Python/ccpi/framework/framework.py +++ b/Wrappers/Python/ccpi/framework/framework.py @@ -827,6 +827,14 @@ class DataContainer(object): def conjugate(self, *args, **kwargs): return self.pixel_wise_unary(numpy.conjugate, *args, **kwargs) + + def exp(self, *args, **kwargs): + '''Applies exp pixel-wise to the DataContainer''' + return self.pixel_wise_unary(numpy.exp, *args, **kwargs) + + 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) diff --git a/Wrappers/Python/test/test_DataContainer.py b/Wrappers/Python/test/test_DataContainer.py index 675e150..9b9a8dd 100755 --- a/Wrappers/Python/test/test_DataContainer.py +++ b/Wrappers/Python/test/test_DataContainer.py @@ -478,6 +478,17 @@ class TestDataContainer(unittest.TestCase): n0 = (ds0 * ds1).sum() n1 = ds0.as_array().ravel().dot(ds1.as_array().ravel()) self.assertEqual(n0, n1) + + def test_exp_log(self): + a0 = numpy.asarray([1 for i in range(2*3*4)]) + + ds0 = DataContainer(numpy.reshape(a0,(2,3,4)), suppress_warning=True) + # ds1 = DataContainer(numpy.reshape(a1,(2,3,4)), suppress_warning=True) + b = ds0.exp().log() + self.assertNumpyArrayEqual(ds0.as_array(), b.as_array()) + + self.assertEqual(ds0.exp().as_array()[0][0][0], numpy.exp(1)) + self.assertEqual(ds0.log().as_array()[0][0][0], 0.) |