diff --git a/dingo/PolytopeSampler.py b/dingo/PolytopeSampler.py index 1e3676e..7c50bbe 100644 --- a/dingo/PolytopeSampler.py +++ b/dingo/PolytopeSampler.py @@ -136,6 +136,8 @@ def generate_steady_states( parallel_mmcs -- a boolean flag to request the parallel mmcs num_threads -- the number of threads to use for parallel mmcs """ + if not isinstance(ess, int) or ess < 10: + raise ValueError("The effective sample size (ess) must be an integer greater than or equal to 10.") self.get_polytope() diff --git a/tests/sampling.py b/tests/sampling.py index a0827d6..d7fe4de 100644 --- a/tests/sampling.py +++ b/tests/sampling.py @@ -51,6 +51,14 @@ def test_sample_sbml(self): self.assertTrue( steady_states.shape[0] == 95 ) self.assertTrue( abs( steady_states[12].mean() - 2.504 ) < 1e-02 ) + + def test_invalid_ess(self): + input_file_json = os.getcwd() + "/ext_data/e_coli_core.json" + model = MetabolicNetwork.from_json(input_file_json) + sampler = PolytopeSampler(model) + + with self.assertRaises(ValueError): + sampler.generate_steady_states(ess=5)