def sample(self, n, fluxes=True):
if self.processes > <NUM_LIT:1>:<EOL><INDENT>n_process = np.ceil(n / self.processes).astype(int)<EOL>n = n_process * self.processes<EOL>args = list(zip(<EOL>[n_process] * self.processes, range(self.processes)))<EOL>mp = Pool(self.processes, initializer=mp_init, initargs=(self,))<EOL>results = mp.map(_sample_chain, args, chunksize=<NUM_LIT:1>)<EOL>mp.close()<EOL>mp.join()<EOL>chains = np.vstack([r[<NUM_LIT:1>] for r in results])<EOL>self.retries += sum(r[<NUM_LIT:0>] for r in results)<EOL><DEDENT>else:<EOL><INDENT>mp_init(self)<EOL>results = _sample_chain((n, <NUM_LIT:0>))<EOL>chains = results[<NUM_LIT:1>]<EOL><DEDENT>self.center = (self.n_samples * self.center +<EOL>np.atleast_2d(chains).sum(<NUM_LIT:0>)) / (self.n_samples + n)<EOL>self.n_samples += n<EOL>if fluxes:<EOL><INDENT>names = [r.id for r in self.model.reactions]<EOL>return pandas.DataFrame(<EOL>chains[:, self.fwd_idx] - chains[:, self.rev_idx],<EOL>columns=names)<EOL><DEDENT>else:<EOL><INDENT>names = [v.name for v in self.model.variables]<EOL>return pandas.DataFrame(chains, columns=names)<EOL><DEDENT>
Generate a set of samples.

        This is the basic sampling function for all hit-and-run samplers.

        Paramters
        ---------
        n : int
            The minimum number of samples that are generated at once
            (see Notes).
        fluxes : boolean
            Whether to return fluxes or the internal solver variables. If set
            to False will return a variable for each forward and backward flux
            as well as all additional variables you might have defined in the
            model.

        Returns
        -------
        numpy.matrix
            Returns a matrix with `n` rows, each containing a flux sample.

        Notes
        -----
        Performance of this function linearly depends on the number
        of reactions in your model and the thinning factor.

        If the number of processes is larger than one, computation is split
        across as the CPUs of your machine. This may shorten computation time.
        However, there is also overhead in setting up parallel computation so
        we recommend to calculate large numbers of samples at once
        (`n` > 1000).