summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdoardo Pasca <edo.paskino@gmail.com>2020-02-06 16:30:12 +0000
committerGitHub <noreply@github.com>2020-02-06 16:30:12 +0000
commit524cdd1fc816ec1cc79d3cf339b694de7f8be00a (patch)
treeea3f621d6e26b38bd4df406e818326c4ff88e75a
parent6e60b7802bb0369cc9dd8b1715073a1ff3c18f03 (diff)
downloadframework-524cdd1fc816ec1cc79d3cf339b694de7f8be00a.tar.gz
framework-524cdd1fc816ec1cc79d3cf339b694de7f8be00a.tar.bz2
framework-524cdd1fc816ec1cc79d3cf339b694de7f8be00a.tar.xz
framework-524cdd1fc816ec1cc79d3cf339b694de7f8be00a.zip
fix limits of docstring (#495)
* fix limits of docstring * add test for IndicatorBox
-rw-r--r--Wrappers/Python/ccpi/optimisation/functions/IndicatorBox.py2
-rw-r--r--Wrappers/Python/test/test_functions.py14
2 files changed, 14 insertions, 2 deletions
diff --git a/Wrappers/Python/ccpi/optimisation/functions/IndicatorBox.py b/Wrappers/Python/ccpi/optimisation/functions/IndicatorBox.py
index 4383858..68f7e04 100644
--- a/Wrappers/Python/ccpi/optimisation/functions/IndicatorBox.py
+++ b/Wrappers/Python/ccpi/optimisation/functions/IndicatorBox.py
@@ -44,10 +44,10 @@ class IndicatorBox(Function):
:type lower: float, default = :code:`-numpy.inf`
:param upper: upper bound
:type upper: float, optional, default = :code:`numpy.inf`
+ '''
super(IndicatorBox, self).__init__()
self.lower = lower
self.upper = upper
- '''
def __call__(self,x):
diff --git a/Wrappers/Python/test/test_functions.py b/Wrappers/Python/test/test_functions.py
index d63ff90..ffb4551 100644
--- a/Wrappers/Python/test/test_functions.py
+++ b/Wrappers/Python/test/test_functions.py
@@ -29,7 +29,7 @@ from ccpi.optimisation.operators import Gradient
from ccpi.optimisation.functions import Function, KullbackLeibler, L2NormSquared,\
L1Norm, MixedL21Norm, LeastSquares, \
ZeroFunction, FunctionOperatorComposition,\
- Rosenbrock
+ Rosenbrock, IndicatorBox
import unittest
import numpy
@@ -447,6 +447,18 @@ class TestFunction(unittest.TestCase):
x = VectorData(numpy.asarray([1,1]))
assert f(x) == 0.
numpy.testing.assert_array_almost_equal( f.gradient(x).as_array(), numpy.zeros(shape=(2,), dtype=numpy.float32))
+ def test_IndicatorBox(self):
+ ig = ImageGeometry(10,10)
+ im = ig.allocate(-1)
+ ib = IndicatorBox(lower=0)
+ a = ib(im)
+ numpy.testing.assert_equal(a, numpy.inf)
+ ib = IndicatorBox(lower=-2)
+ a = ib(im)
+ numpy.testing.assert_array_equal(0, a)
+ ib = IndicatorBox(lower=-5, upper=-2)
+ a = ib(im)
+ numpy.testing.assert_equal(a, numpy.inf)
if __name__ == '__main__':