def set_prox(self, prox: Prox): """Set proximal operator in the solver Parameters ---------- prox : `Prox` The proximal operator of the penalization function Returns ------- output : `Solver` The solver with given prox Notes ----- In some solvers, ``set_model`` must be called before ``set_prox``, otherwise and error might be raised """ if not isinstance(prox, Prox): raise ValueError('Passed object of class %s is not a ' 'Prox class' % prox.name) if self.dtype is None or self.model is None: raise ValueError("Solver must call set_model before set_prox") if prox.dtype != self.dtype: prox = prox.astype(self.dtype) self._set("prox", prox) return self
def set_prox(self, prox: Prox): if prox._prox is None: raise ValueError("Prox %s is not compatible with stochastic " "solver %s" % (prox.__class__.__name__, self.__class__.__name__)) # Give the C++ wrapped prox to the solver if self.dtype is None or self.model is None: raise ValueError("Solver must call set_model before set_prox") if prox.dtype != self.dtype: prox = prox.astype(self.dtype) self._solver.set_prox(prox._prox) return self