(self, func, *args, nprocs=None, **kwargs)
return self
Evaluate model locally in parallel.

        All detected processors will be used if `nprocs` is not specified.

        Parameters
        ----------
        func : function,
            Model, or function that wraps a model, to be run in parallel.
            The provided function needs to accept a numpy array of inputs as
            its first parameter and must return a numpy array of results.

        nprocs : int,
            Number of processors to use.
            Capped to the number of available processors.

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

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

        Returns
        ----------
        self : ProblemSpec object
Evaluate model locally in parallel.
Evaluate model locally in parallel .
def evaluate_parallel(self, func, *args, nprocs=None, **kwargs):
        """Evaluate model locally in parallel.

        All detected processors will be used if `nprocs` is not specified.

        Parameters
        ----------
        func : function,
            Model, or function that wraps a model, to be run in parallel.
            The provided function needs to accept a numpy array of inputs as
            its first parameter and must return a numpy array of results.

        nprocs : int,
            Number of processors to use.
            Capped to the number of available processors.

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

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

        Returns
        ----------
        self : ProblemSpec object
        """
        warnings.warn("Parallel evaluation is an experimental feature and may not work.")

        if self._samples is None:
            raise RuntimeError("Sampling not yet conducted")

        max_procs = cpu_count()
        if nprocs is None:
            nprocs = max_procs
        else:
            if nprocs > max_procs:
                warnings.warn(f"{nprocs} processors requested but only {max_procs} found.")
            nprocs = min(max_procs, nprocs)

        # Create wrapped partial function to allow passing of additional args
        tmp_f = self._wrap_func(func, *args, **kwargs)

        # Split into even chunks
        chunks = np.array_split(self._samples, int(nprocs), axis=0)

        if ptqdm_available:
            # Display progress bar if available
            res = p_imap(tmp_f, chunks, num_cpus=nprocs)
        else:
            with Pool(nprocs) as pool:
                res = list(pool.imap(tmp_f, chunks))

        self.results = self._collect_results(res)

        return self
def evaluate_parallel ( self , func , * args , nprocs = None , * * kwargs ) : warnings . warn ( "Parallel evaluation is an experimental feature and may not work." ) if self . _samples is None : raise RuntimeError ( "Sampling not yet conducted" ) max_procs = cpu_count ( ) if nprocs is None : nprocs = max_procs else : if nprocs > max_procs : warnings . warn ( f"{nprocs} processors requested but only {max_procs} found." ) nprocs = min ( max_procs , nprocs ) # Create wrapped partial function to allow passing of additional args tmp_f = self . _wrap_func ( func , * args , * * kwargs ) # Split into even chunks chunks = np . array_split ( self . _samples , int ( nprocs ) , axis = 0 ) if ptqdm_available : # Display progress bar if available res = p_imap ( tmp_f , chunks , num_cpus = nprocs ) else : with Pool ( nprocs ) as pool : res = list ( pool . imap ( tmp_f , chunks ) ) self . results = self . _collect_results ( res ) return self