fides/minimize.py
def check_finite(self,
                     grad: Optional[np.ndarray] = None,
                     hess: Optional[np.ndarray] = None):
        """
        Checks whether objective function value, gradient and Hessian (
        approximation) have finite values and optimization can continue.

        :param grad:
            gradient to be checked for finiteness, if not provided, current
            one will be checked

        :param hess:
            Hessian (approximation) to be checked for finiteness, if not
            provided, current one will be checked

        :raises:
            RuntimeError if any of the variables have non-finite entries
        """

        if self.iteration == 0:
            pointstr = 'at initial point.'
        else:
            pointstr = f'at iteration {self.iteration}.'

        if grad is None:
            grad = self.grad

        if hess is None:
            hess = self.hess

        if not np.isfinite(self.fval):
            self.exitflag = ExitFlag.NOT_FINITE
            raise RuntimeError(f'Encountered non-finite function {self.fval} '
                               f'value {pointstr}')

        if not np.isfinite(grad).all():
            self.exitflag = ExitFlag.NOT_FINITE
            ix = np.where(np.logical_not(np.isfinite(grad)))
            raise RuntimeError('Encountered non-finite gradient entries'
                               f' {grad[ix]} for indices {ix} '
                               f'{pointstr}')

        if not np.isfinite(hess).all():
            self.exitflag = ExitFlag.NOT_FINITE
            ix = np.where(np.logical_not(np.isfinite(hess)))
            raise RuntimeError('Encountered non-finite gradient hessian'
                               f' {hess[ix]} for indices {ix} '
                               f'{pointstr}')

        Checks whether objective function value, gradient and Hessian (
        approximation) have finite values and optimization can continue.

        :param grad:
            gradient to be checked for finiteness, if not provided, current
            one will be checked

        :param hess:
            Hessian (approximation) to be checked for finiteness, if not
            provided, current one will be checked

        :raises:
            RuntimeError if any of the variables have non-finite entries
        
Checks whether objective function value, gradient and Hessian (
approximation) have finite values and optimization can continue.
Checks whether objective function value gradient and Hessian ( approximation ) have finite values and optimization can continue .
def check_finite(self,
                     grad: Optional[np.ndarray] = None,
                     hess: Optional[np.ndarray] = None):
        if self.iteration == 0:
            pointstr = 'at initial point.'
        else:
            pointstr = f'at iteration {self.iteration}.'
        if grad is None:
            grad = self.grad
        if hess is None:
            hess = self.hess
        if not np.isfinite(self.fval):
            self.exitflag = ExitFlag.NOT_FINITE
            raise RuntimeError(f'Encountered non-finite function {self.fval} '
                               f'value {pointstr}')
        if not np.isfinite(grad).all():
            self.exitflag = ExitFlag.NOT_FINITE
            ix = np.where(np.logical_not(np.isfinite(grad)))
            raise RuntimeError('Encountered non-finite gradient entries'
                               f' {grad[ix]} for indices {ix} '
                               f'{pointstr}')
        if not np.isfinite(hess).all():
            self.exitflag = ExitFlag.NOT_FINITE
            ix = np.where(np.logical_not(np.isfinite(hess)))
            raise RuntimeError('Encountered non-finite gradient hessian'
                               f' {hess[ix]} for indices {ix} '
                               f'{pointstr}')
def check_finite ( self , grad : Optional [ np . ndarray ] = None , hess : Optional [ np . ndarray ] = None ) : if self . iteration == 0 : pointstr = 'at initial point.' else : pointstr = f'at iteration {self.iteration}.' if grad is None : grad = self . grad if hess is None : hess = self . hess if not np . isfinite ( self . fval ) : self . exitflag = ExitFlag . NOT_FINITE raise RuntimeError ( f'Encountered non-finite function {self.fval} ' f'value {pointstr}' ) if not np . isfinite ( grad ) . all ( ) : self . exitflag = ExitFlag . NOT_FINITE ix = np . where ( np . logical_not ( np . isfinite ( grad ) ) ) raise RuntimeError ( 'Encountered non-finite gradient entries' f' {grad[ix]} for indices {ix} ' f'{pointstr}' ) if not np . isfinite ( hess ) . all ( ) : self . exitflag = ExitFlag . NOT_FINITE ix = np . where ( np . logical_not ( np . isfinite ( hess ) ) ) raise RuntimeError ( 'Encountered non-finite gradient hessian' f' {hess[ix]} for indices {ix} ' f'{pointstr}' )
Checks whether objective function value, gradient and Hessian (
approximation) have finite values and optimization can continue.
Checks whether objective function value gradient and Hessian ( approximation ) have finite values and optimization can continue .
"""
        Checks whether objective function value, gradient and Hessian (
        approximation) have finite values and optimization can continue.

        :param grad:
            gradient to be checked for finiteness, if not provided, current
            one will be checked

        :param hess:
            Hessian (approximation) to be checked for finiteness, if not
            provided, current one will be checked

        :raises:
            RuntimeError if any of the variables have non-finite entries
        """
RuntimeError if any of the variables have non-finite entries
RuntimeError if any of the variables have non - finite entries
self
grad
Optional[np.ndarray]
gradient to be checked for finiteness, if not provided, current
one will be checked
gradient to be checked for finiteness if not provided current one will be checked
hess
Optional[np.ndarray]
Hessian (approximation) to be checked for finiteness, if not
provided, current one will be checked
Hessian ( approximation ) to be checked for finiteness if not provided current one will be checked