(self, func, *args, **kwargs)
return self
Analyze sampled results using given function.

        Parameters
        ----------
        func : function,
            Analysis method to use. The provided function must accept the
            problem specification as the first parameter, X values if needed,
            Y values, and return a numpy array.

        *args : list,
            Additional arguments to be passed to `func`

        nprocs : int,
            If specified, attempts to parallelize model evaluations

        **kwargs : dict,
            Additional keyword arguments passed to `func`

        Returns
        ----------
        self : ProblemSpec object
Analyze sampled results using given function.
Analyze sampled results using given function .
def analyze(self, func, *args, **kwargs):
        """Analyze sampled results using given function.

        Parameters
        ----------
        func : function,
            Analysis method to use. The provided function must accept the
            problem specification as the first parameter, X values if needed,
            Y values, and return a numpy array.

        *args : list,
            Additional arguments to be passed to `func`

        nprocs : int,
            If specified, attempts to parallelize model evaluations

        **kwargs : dict,
            Additional keyword arguments passed to `func`

        Returns
        ----------
        self : ProblemSpec object
        """
        if 'nprocs' in kwargs:
            # Call parallel method instead
            return self.analyze_parallel(func, *args, **kwargs)

        if self._results is None:
            raise RuntimeError("Model not yet evaluated")

        if 'X' in func.__code__.co_varnames:
            # enforce passing of X if expected
            func = partial(func, *args, X=self._samples, **kwargs)
        else:
            func = partial(func, *args, **kwargs)

        out_cols = self.get('outputs', None)
        if out_cols is None:
            if len(self._results.shape) == 1:
                self['outputs'] = ['Y']
            else:
                num_cols = self._results.shape[1]
                self['outputs'] = [f'Y{i}' for i in range(1, num_cols+1)]

        if len(self['outputs']) > 1:
            self._analysis = {}
            for i, out in enumerate(self['outputs']):
                self._analysis[out] = func(self, Y=self._results[:, i])
        else:
            self._analysis = func(self, Y=self._results)

        return self
def analyze ( self , func , * args , * * kwargs ) : if 'nprocs' in kwargs : # Call parallel method instead return self . analyze_parallel ( func , * args , * * kwargs ) if self . _results is None : raise RuntimeError ( "Model not yet evaluated" ) if 'X' in func . __code__ . co_varnames : # enforce passing of X if expected func = partial ( func , * args , X = self . _samples , * * kwargs ) else : func = partial ( func , * args , * * kwargs ) out_cols = self . get ( 'outputs' , None ) if out_cols is None : if len ( self . _results . shape ) == 1 : self [ 'outputs' ] = [ 'Y' ] else : num_cols = self . _results . shape [ 1 ] self [ 'outputs' ] = [ f'Y{i}' for i in range ( 1 , num_cols + 1 ) ] if len ( self [ 'outputs' ] ) > 1 : self . _analysis = { } for i , out in enumerate ( self [ 'outputs' ] ) : self . _analysis [ out ] = func ( self , Y = self . _results [ : , i ] ) else : self . _analysis = func ( self , Y = self . _results ) return self