def validate(self, samples):
samples = np.atleast_2d(samples)<EOL>prob = self.problem<EOL>if samples.shape[<NUM_LIT:1>] == len(self.model.reactions):<EOL><INDENT>S = create_stoichiometric_matrix(self.model)<EOL>b = np.array([self.model.constraints[m.id].lb for m in<EOL>self.model.metabolites])<EOL>bounds = np.array([r.bounds for r in self.model.reactions]).T<EOL><DEDENT>elif samples.shape[<NUM_LIT:1>] == len(self.model.variables):<EOL><INDENT>S = prob.equalities<EOL>b = prob.b<EOL>bounds = prob.variable_bounds<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>feasibility = np.abs(S.dot(samples.T).T - b).max(axis=<NUM_LIT:1>)<EOL>lb_error = (samples - bounds[<NUM_LIT:0>, ]).min(axis=<NUM_LIT:1>)<EOL>ub_error = (bounds[<NUM_LIT:1>, ] - samples).min(axis=<NUM_LIT:1>)<EOL>if (samples.shape[<NUM_LIT:1>] == len(self.model.variables) and<EOL>prob.inequalities.shape[<NUM_LIT:0>]):<EOL><INDENT>consts = prob.inequalities.dot(samples.T)<EOL>lb_error = np.minimum(<EOL>lb_error,<EOL>(consts - prob.bounds[<NUM_LIT:0>, ]).min(axis=<NUM_LIT:1>))<EOL>ub_error = np.minimum(<EOL>ub_error,<EOL>(prob.bounds[<NUM_LIT:1>, ] - consts).min(axis=<NUM_LIT:1>)<EOL>)<EOL><DEDENT>valid = (<EOL>(feasibility < self.feasibility_tol) &<EOL>(lb_error > -self.bounds_tol) &<EOL>(ub_error > -self.bounds_tol))<EOL>codes = np.repeat("<STR_LIT>", valid.shape[<NUM_LIT:0>]).astype(np.dtype((str, <NUM_LIT:3>)))<EOL>codes[valid] = "<STR_LIT:v>"<EOL>codes[lb_error <= -self.bounds_tol] = np.char.add(<EOL>codes[lb_error <= -self.bounds_tol], "<STR_LIT:l>")<EOL>codes[ub_error <= -self.bounds_tol] = np.char.add(<EOL>codes[ub_error <= -self.bounds_tol], "<STR_LIT:u>")<EOL>codes[feasibility > self.feasibility_tol] = np.char.add(<EOL>codes[feasibility > self.feasibility_tol], "<STR_LIT:e>")<EOL>return codes<EOL>
Validate a set of samples for equality and inequality feasibility.

        Can be used to check whether the generated samples and warmup points
        are feasible.

        Parameters
        ----------
        samples : numpy.matrix
            Must be of dimension (n_samples x n_reactions). Contains the
            samples to be validated. Samples must be from fluxes.

        Returns
        -------
        numpy.array
            A one-dimensional numpy array of length containing
            a code of 1 to 3 letters denoting the validation result:

            - 'v' means feasible in bounds and equality constraints
            - 'l' means a lower bound violation
            - 'u' means a lower bound validation
            - 'e' means and equality constraint violation