From c324276a3fc2b0fec6c938691fb61c4b42442751 Mon Sep 17 00:00:00 2001 From: Edoardo Pasca Date: Tue, 8 Jan 2019 17:06:55 +0000 Subject: Norm2sq does not fail if cannot calculate Lipschitz constant --- Wrappers/Python/ccpi/optimisation/funcs.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'Wrappers/Python') 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 ) -- cgit v1.2.3