From 3295932495e097cfd827ea9f482dfd871b5168e0 Mon Sep 17 00:00:00 2001 From: Rahul Kumar Date: Thu, 28 Mar 2024 15:31:54 +0530 Subject: [PATCH 1/3] Update README installation instructions to be more user friendly #89 (#91) * Update README installation instructions to be more user friendly #89 * Update README.md * Update README.md * Update dingo_walkthrough.ipynb * Update README.md * Delete tutorials/dingo_walkthrough.ipynb --- .gitignore | 3 +++ README.md | 21 +++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 8ef6839e..23c482eb 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,6 @@ volestipy.egg-info .ipynb_checkpoints/ .vscode venv +lp_solve_5.5/ +.devcontainer/ +.github/dependabot.yml \ No newline at end of file diff --git a/README.md b/README.md index 486271ad..13b23af2 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,22 @@ metabolic network, namely Flux Balance Analysis and Flux Variability Analysis. [![Tutorial In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/GeomScale/dingo/blob/develop/tutorials/dingo_tutorial.ipynb) [![Chat](https://badges.gitter.im/geomscale.png)](https://gitter.im/GeomScale/community?utm_source=share-link&utm_medium=link&utm_campaign=share-link) + ## Installation +**Note:** Python version should be 3.8.x. You can check this by running the following command in your terminal: +```bash +python --version +``` +If you have a different version of Python installed, you'll need to install it ([start here](https://linuxize.com/post/how-to-install-python-3-8-on-ubuntu-18-04/)) and update-alternatives ([start here](https://linuxhint.com/update_alternatives_ubuntu/)) + +**Note:** If you are using `GitHub Codespaces`. Start [here](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/setting-up-your-python-project-for-codespaces) to set the python version. Once your Python version is `3.8.x` you can start following the below instructions. + + + To load the submodules that dingo uses, run -````unix +````bash git submodule update --init ```` @@ -39,12 +50,14 @@ rm lp_solve_5.5.2.11_source.tar.gz Then, you need to install the dependencies for the PySPQR library; for Debian/Ubuntu Linux, run -``` -apt-get install libsuitesparse-dev +```bash +sudo apt-get update -y +sudo apt-get install -y libsuitesparse-dev ``` -To install the Python dependencies, install [Poetry](https://python-poetry.org/). Then, run +To install the Python dependencies, to install [Poetry](https://python-poetry.org/), run ``` +curl -sSL https://install.python-poetry.org | python3 - --version 1.3.2 poetry shell poetry install ``` From 1d601809ba14d7c31ca6d60901622d9d0e9b6070 Mon Sep 17 00:00:00 2001 From: vfisikop <160006479+vfisikop@users.noreply.github.com> Date: Thu, 28 Mar 2024 12:04:14 +0200 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 13b23af2..1dbe7733 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ sudo apt-get update -y sudo apt-get install -y libsuitesparse-dev ``` -To install the Python dependencies, to install [Poetry](https://python-poetry.org/), run +To install the Python dependencies, `dingo` is using [Poetry](https://python-poetry.org/), ``` curl -sSL https://install.python-poetry.org | python3 - --version 1.3.2 poetry shell From c51f0a5b6a461e9405a548f1ae44f35d4bee86bf Mon Sep 17 00:00:00 2001 From: Vissarion Fisikopoulos Date: Thu, 28 Mar 2024 16:14:16 +0200 Subject: [PATCH 3/3] Fix rounding test (#92) Co-authored-by: vfisikop --- tests/rounding.py | 60 ++++++++++------------------------------------- 1 file changed, 13 insertions(+), 47 deletions(-) diff --git a/tests/rounding.py b/tests/rounding.py index 7caa4cd5..dcf4cedb 100644 --- a/tests/rounding.py +++ b/tests/rounding.py @@ -2,7 +2,7 @@ # dingo is part of GeomScale project # Copyright (c) 2022 Apostolos Chalkis -# Copyright (c) 2022 Vissarion Fisikopoulos +# Copyright (c) 2022-2024 Vissarion Fisikopoulos # Copyright (c) 2022 Haris Zafeiropoulos # Licensed under GNU LGPL.3, see LICENCE file @@ -13,9 +13,7 @@ from dingo import MetabolicNetwork, PolytopeSampler from dingo.gurobi_based_implementations import fast_inner_ball -class TestSampling(unittest.TestCase): - - def test_rounding_min_ellipsoid(self): +def test_rounding(self, method_str): input_file_json = os.getcwd() + "/ext_data/e_coli_core.json" model = MetabolicNetwork.from_json( input_file_json ) @@ -23,7 +21,7 @@ def test_rounding_min_ellipsoid(self): A, b, N, N_shift = sampler.get_polytope() - A_rounded, b_rounded, Tr, Tr_shift = sampler.round_polytope(A, b, method="min_ellipsoid") + A_rounded, b_rounded, Tr, Tr_shift = sampler.round_polytope(A, b, method = method_str) self.assertTrue( A_rounded.shape[0] == 26 ) self.assertTrue( A_rounded.shape[1] == 24 ) @@ -32,46 +30,7 @@ def test_rounding_min_ellipsoid(self): self.assertTrue( N_shift.size == 95 ) self.assertTrue( b_rounded.size == 26 ) self.assertTrue( Tr_shift.size == 24 ) - - - self.assertTrue( N.shape[0] == 95 ) - self.assertTrue( N.shape[1] == 24 ) - self.assertTrue( Tr.shape[0] == 24 ) - self.assertTrue( Tr.shape[1] == 24 ) - - samples = sampler.sample_from_polytope_no_multiphase( - A_rounded, b_rounded, method = 'billiard_walk', n=1000, burn_in=10, thinning=1 - ) - - temp = np.full((samples.shape[0], samples.shape[1]), Tr_shift) - Tr_samples = Tr.dot(samples.T) + temp.T - all_points_in = True - for i in range(Tr_samples.shape[1]): - if np.any(A.dot(Tr_samples[:,i]) - b > 1e-05): - all_points_in = False - break - - self.assertTrue( all_points_in ) - - def test_rounding_john_position(self): - - input_file_json = os.getcwd() + "/ext_data/e_coli_core.json" - model = MetabolicNetwork.from_json( input_file_json ) - sampler = PolytopeSampler(model) - - A, b, N, N_shift = sampler.get_polytope() - - A_rounded, b_rounded, Tr, Tr_shift = sampler.round_polytope(A, b, method="john_position") - - self.assertTrue( A_rounded.shape[0] == 26 ) - self.assertTrue( A_rounded.shape[1] == 24 ) - - self.assertTrue( b.size == 26 ) - self.assertTrue( N_shift.size == 95 ) - self.assertTrue( b_rounded.size == 26 ) - self.assertTrue( Tr_shift.size == 24 ) - self.assertTrue( N.shape[0] == 95 ) self.assertTrue( N.shape[1] == 24 ) @@ -83,18 +42,25 @@ def test_rounding_john_position(self): A_rounded, b_rounded, method = 'billiard_walk', n=1000, burn_in=10, thinning=1 ) - temp = np.full((samples.shape[0], samples.shape[1]), Tr_shift) - Tr_samples = Tr.dot(samples.T) + temp.T + Tr_shift = Tr_shift.reshape(Tr_shift.shape[0], 1) + Tr_shift_mat = np.full((samples.shape[0], samples.shape[1]), Tr_shift) + Tr_samples = Tr.dot(samples) + Tr_shift_mat + all_points_in = True for i in range(Tr_samples.shape[1]): if np.any(A.dot(Tr_samples[:,i]) - b > 1e-05): all_points_in = False break - + self.assertTrue( all_points_in ) +class TestSampling(unittest.TestCase): + def test_rounding_min_ellipsoid(self): + test_rounding(self, "min_ellipsoid") + def test_rounding_john_position(self): + test_rounding(self, "john_position") if __name__ == "__main__": unittest.main() \ No newline at end of file