summaryrefslogtreecommitdiffstats
path: root/Wrappers/Python
diff options
context:
space:
mode:
Diffstat (limited to 'Wrappers/Python')
-rwxr-xr-xWrappers/Python/ccpi/optimisation/funcs.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/Wrappers/Python/ccpi/optimisation/funcs.py b/Wrappers/Python/ccpi/optimisation/funcs.py
index 2266560..c7a6143 100755
--- a/Wrappers/Python/ccpi/optimisation/funcs.py
+++ b/Wrappers/Python/ccpi/optimisation/funcs.py
@@ -136,6 +136,8 @@ class Norm2sq(Function):
'''
def __init__(self,A,b,c=1.0,memopt=False):
+ super(Norm2sq, self).__init__()
+
self.A = A # Should be an operator, default identity
self.b = b # Default zero DataSet?
self.c = c # Default 1.
@@ -146,11 +148,13 @@ class Norm2sq(Function):
self.adjoint_placehold = A.allocate_adjoint()
- # Compute the Lipschitz parameter from the operator.
- # Initialise to None instead and only call when needed.
- self.L = 2.0*self.c*(self.A.get_max_sing_val()**2)
- super(Norm2sq, self).__init__()
-
+ # Compute the Lipschitz parameter from the operator if possible
+ # Leave it initialised to None otherwise
+ try:
+ self.L = 2.0*self.c*(self.A.get_max_sing_val()**2)
+ except AttributeError as ae:
+ pass
+
def grad(self,x):
#return 2*self.c*self.A.adjoint( self.A.direct(x) - self.b )
return (2.0*self.c)*self.A.adjoint( self.A.direct(x) - self.b )