[med-svn] [python-cobra] 04/08: Imported Upstream version 0.5.2

Afif Elghraoui afif at moszumanska.debian.org
Sat Oct 22 06:03:51 UTC 2016


This is an automated email from the git hooks/post-receive script.

afif pushed a commit to branch master
in repository python-cobra.

commit 9170c9461df0004f6f9ba7b657b7e5b2d734309b
Author: Afif Elghraoui <afif at debian.org>
Date:   Fri Oct 21 21:32:23 2016 -0700

    Imported Upstream version 0.5.2
---
 .travis.yml                                  |  96 +++++----------
 CONTRIBUTING.rst                             | 171 ++++++++++++++++++++++++---
 INSTALL.rst                                  |  77 +++++-------
 README.rst                                   |  77 +++++++++---
 cobra/VERSION                                |   2 +-
 cobra/core/ArrayBasedModel.py                |  21 ++--
 cobra/flux_analysis/phenotype_phase_plane.py |  15 ++-
 cobra/flux_analysis/variability.py           |  23 ++--
 cobra/test/data/textbook_solution.pickle     | Bin 0 -> 5278 bytes
 cobra/test/data/update_pickles.py            |   5 +
 cobra/test/flux_analysis.py                  |  36 ++++--
 cobra/test/unit_tests.py                     |  16 ++-
 config.sh                                    |  29 ++---
 develop-requirements.txt                     |  15 +++
 documentation_builder/faq.ipynb              |   2 +-
 documentation_builder/index.rst              |   5 +-
 make-mac-wheels.sh                           |  14 +++
 manylinux_builder/build_cobrapy.sh           |   1 +
 scripts/deploy.sh                            |   3 +-
 tox.ini                                      |  12 ++
 20 files changed, 413 insertions(+), 207 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 424b609..345cc0a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,77 +1,43 @@
 language: python
-python: 3.5
-sudo: required
-dist: trusty
-services: docker
-sudo: required
+sudo: false
 cache:
   directories:
     - $HOME/.cache/pip
+python:
+  - "2.7"
+  - "3.4"
+  - "3.5"
 addons:
   apt:
     packages:
-      - libfreetype6-dev
-      - libpng12-dev
-
+      - gfortran
+      - libatlas-dev
+      - libatlas-base-dev
+      - liblapack-dev
+      - libgmp-dev
+      - libglpk-dev
+      - libmpfr-dev
+
+# command to install dependencies
 env:
-  global:
-    - secure: "hkKBaGLvoDVgktSKR3BmX+mYlGzHw9EO11MRHtiH8D9BbdygOR9p9aSV/OxkaRWhnkSP5/0SXqVgBrvU1g5OsR6cc85UQSpJ5H5jVnLoWelIbTxMCikjxDSkZlseD7ZEWrKZjRo/ZN2qym0HRWpsir3qLpl8W25xHRv/sK7Z6g8="
-    - secure: "DflyBz+QiyhlhBxn4wN00xu248EJUMjKTxUZQN6wq22qV55xO3ToGJTy9i4D6OBfZGAlSXxjjKCJ2+0sAjsghBSDEK56ud3EEg/08TIo7/T8ex/C58FsGoGFz3yDBATmquClEWN8vAMrLdxwniHmQVCBZCP/phdt5dct0AUuDc8="
-    - PLAT=x86_64
-    - UNICODE_WIDTH=32
-
-matrix:
-  exclude:
-      - python: 3.5
-  include:
-    - os: linux
-      env:
-        - MB_PYTHON_VERSION=2.7
-    - os: linux
-      env:
-        - MB_PYTHON_VERSION=3.4
-    - os: linux
-      env:
-        - MB_PYTHON_VERSION=3.5
-    - os: osx
-      language: objective-c
-      env:
-        - MB_PYTHON_VERSION=2.7
-    - os: osx
-      language: objective-c
-      env:
-        - MB_PYTHON_VERSION=3.4
-    - os: osx
-      language: objective-c
-      env:
-        - MB_PYTHON_VERSION=3.5
-
+  - PIP_CACHE_DIR=$HOME/.cache/pip
 before_install:
-  - (git clone https://github.com/matthew-brett/multibuild.git && cd multibuild && git checkout d7ba4ae)
-  # matplotlib non-compatible as testing runs in venv (non-framework)
-  - TEST_DEPENDS="cython codecov coverage numpy scipy python-libsbml jsonschema six pandas tabulate"
-  - BUILD_DEPENDS="cython numpy scipy"
-  - source multibuild/common_utils.sh
-  - source multibuild/travis_steps.sh
-  - before_install
-
-before_cache:
-  - set +e
-
+  - pip install pip --upgrade
+  # These get cached
+  - pip install numpy scipy python-libsbml cython codecov jsonschema six matplotlib pandas
+  - if [[ $TRAVIS_PYTHON_VERSION == 2* ]]; then pip install lxml glpk pep8 palettable; fi
+  # Download esolver and add it to the path
+  - wget https://opencobra.github.io/pypi_cobrapy_travis/esolver.gz
+  - gzip -d esolver.gz; chmod +x esolver; export PATH=$PATH:$PWD
+  - mkdir -p $HOME/.config/matplotlib
+  - "echo 'backend: Agg' >> $HOME/.config/matplotlib/matplotlibrc"
 install:
-  - build_wheel . $PLAT
-
+  - python setup.py develop
+# # command to run tests
 script:
-  - if [[ $TRAVIS_OS_NAME == "linux" ]]; then pip install pip --upgrade; pip install pep8; pep8 cobra --exclude=oven,solvers,sbml.py --show-source; fi
-  - install_run $PLAT
-
-deploy:
-  provider: script
-  skip_cleanup: true
-  script: scripts/deploy.sh
-  on:
-    branch: master
-    tags: true
-
+  - coverage run --source=cobra setup.py test
+  - if [[ $TRAVIS_PYTHON_VERSION == 2* ]]; then
+    pep8 cobra --exclude=oven,solvers,sbml.py --show-source;
+    fi
 after_success:
-  - if [[ $TRAVIS_OS_NAME == "linux" ]]; then pip install pip --upgrade; pip install codecov; codecov; fi
+  - codecov
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 8623ea4..937460c 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -1,20 +1,159 @@
-Contribution Guidelines
+.. Highlight:: shell
+
+============
+Contributing
+============
+
+Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
+
+You can contribute in many ways:
+
+Types of Contributions
+----------------------
+
+Report Bugs
+~~~~~~~~~~~
+
+Report bugs using the `issue tracker <https://github.com/opencobra/cobrapy/issues>`__  
+
+If you are reporting a bug, please include:
+
+* Your operating system name and version.
+* Any details about your local setup that might be helpful in troubleshooting.
+* Detailed steps to reproduce the bug.
+
+Fix Bugs
+~~~~~~~~
+
+Look through the GitHub `issues <https://github.com/opencobra/cobrapy/issues>`__ for bugs. Anything tagged with "bug" and "help wanted" is open to whoever wants to
+implement it.
+
+Implement Features
+~~~~~~~~~~~~~~~~~~
+
+Look through the GitHub `issues <https://github.com/opencobra/cobrapy/issues>`__ and `projects <https://github.com/opencobra/cobrapy/projects>`__ for features. Anything tagged with "enhancement" and "help wanted" is open to whoever wants to implement it.
+
+Write Documentation
+~~~~~~~~~~~~~~~~~~~
+
+cobrapy could always use more documentation, whether as part of the official cobrapy docs, in docstrings, or even on the web in blog posts, articles, and such - all contributions are welcome!
+
+Submit Feedback
+~~~~~~~~~~~~~~~
+
+The best way to send feedback is to file an `issue <https://github.com/opencobra/cobrapy/issues>`__.
+
+If you are proposing a feature:
+
+* Explain in detail how it would work.
+* Keep the scope as narrow as possible, to make it easier to implement.
+* Remember that this is a volunteer-driven project, and that contributions
+  are welcome :)
+
+If you like cobrapy please remember to 'star' our github page (click on the star at top right corner), that way we also have an idea of who is using cobrapy!
+
+Get Started!
+------------
+
+Want to contribute a new feature or improvement? Consider starting by raising an issue and assign it to yourself to
+describe what you want to achieve. This way, we reduce the risk of duplicated efforts and you may also get
+suggestions on how to best proceed, e.g. there may be half-finished work in some branch that you could start with.
+
+Here's how to set up `cobrapy` for local development to contribute smaller features or changes that you can implement yourself.
+
+1. Fork the `cobrapy` repository on GitHub.
+2. Clone your fork locally::
+
+    $ git clone git at github.com:your_name_here/cobrapy.git
+
+3. Install libglpk using your package manager. For macOS::
+
+	$ brew install homebrew/science/glpk
+
+   For Debian-based Linux systems (including Ubuntu and Mint)::
+
+	$ sudo apt-get install libglpk-dev
+
+4. If virtualenvwrapper is not installed, `follow the directions <https://virtualenvwrapper.readthedocs.io/en/latest/>`__
+   to install virtualenvwrapper.
+
+5. Install your local copy of cobrapy into a virtualenv with virtualenvwrapper::
+
+    $ cd cobrapy
+    $ mkvirtualenv cobrapy
+
+   Use the ``--python`` option to select a specific version of Python for the virtualenv. Note on macOS, matplotlib
+   requires Python be installed as a framework but virtualenv creates a non-framework build of Python.
+   See the `matplotlib FAQ <http://matplotlib.org/1.5.3/faq/virtualenv_faq.html>`__ for details
+   on a workaround.
+
+6. Install the required packages for development in the virtualenv using pip install::
+
+   (cobrapy)$ pip install --upgrade pip
+   (cobrapy)$ pip install -r develop-requirements.txt
+
+7. Setup cobrapy for development::
+
+    (cobrapy)$ python setup.py develop
+
+8. Create a branch for local development (see below for details on the branching model)::
+
+    (cobrapy)$ git checkout -b name-of-your-bugfix-or-feature
+
+   Now you can make your changes locally.
+
+5. When you are done making changes, check that your changes pass pep8 and the tests with tox for the supported
+   Python versions::
+
+    (cobrapy)$ tox -e py27
+    (cobrapy)$ tox -e py34
+    (cobrapy)$ tox -e py35
+
+6. Commit your changes and push your branch to GitHub::
+
+    (cobrapy)$ git add .
+    (cobrapy)$ git commit -m "Your detailed description of your changes."
+    (cobrapy)$ git push origin name-of-your-bugfix-or-feature
+
+7. Submit a pull request through the GitHub website.
+
+For larger features that you want to work on collaboratively with other cobrapy team members, you may consider to first request to join the cobrapy developers team to get write access to the repository so that you can create a branch in the main repository (or simply ask the maintainer to create a branch for you). Once you have a new branch you can push your changes directly to the main repository and when finished, submit a pull request from that branch to ``devel``.
+
+Pull Request Guidelines
 -----------------------
 
-Generally, the following practices are recommended for making
-contributions to cobrapy. These aren't all necessarily hard-and-fast
-rules, but should serve as guidelines in most cases.
-
-1. Please comment code.
-2. All new python code should be pep8 compliant.
-3. Please use git best practices, with a 50 line summary for each
-   commit. Generally, separate features should be made in separate
-   commits so they can be tested and merged independently. For example,
-   adding a new solver would be a separate commit from fixing whitespace
-   in cobra.core.
-4. Documentation is written as IPython/jupyter notebooks in the
-   ``documentation_builder`` directory, which are then converted to rst
-   by the ``autodoc.sh`` script.
+Before you submit a pull request, check that it meets these guidelines:
+
+1. The pull request should include tests in the ``cobra/test``
+   directory. Except in rare circumstances, code coverage must
+   not decrease (as reported by codecov which runs automatically when
+   you submit your pull request)
+2. If the pull request adds functionality, the docs should be
+   updated. Put your new functionality into a function with a
+   docstring and consider creating a notebook that demonstrates the
+   usage in ``documentation_builder`` (documentation is written as
+   jupyter notebooks in the ``documentation_builder`` directory, which
+   are then converted to rst by the ``autodoc.sh`` script.)
+3. The pull request should work for Python 2.7, 3.4 and 3.5. Check
+   https://travis-ci.org/biosustain/cobrapy/pull_requests
+   and make sure that the tests pass for all supported Python versions.
+4. Assign a reviewer to your pull request. If in doubt, assign Henning
+   Redestig. Your pull request must be approved by at least one
+   reviewer before it can be merged.
+
+Branching model
+---------------
+
+``devel``
+    Is the branch all pull-requests should be based on.
+``master``
+    Is only touched by maintainers and is the branch with only tested, reviewed code that is released or ready for the
+    next release.
+``{fix, bugfix, doc, feature}/descriptive-name``
+    Is the recommended naming scheme for smaller improvements, bugfixes, documentation improvement and new features respectively.
+
+Please use concise descriptive commit messages and consider using ``git pull --rebase`` when you update your own fork to avoid merge commits.
+
 5. Tests are in the ``cobra/test`` directory. They are automatically run
    through continuous integration services on both python 2 and python 3
    when pull requests are made.
@@ -23,4 +162,4 @@ rules, but should serve as guidelines in most cases.
 7. Ensure code will work with both python 2 and python 3. For example,
    instead of ``my_dict.iteritems()`` use ``six.iteritems(my_dict)``
 
-Thank you very much for contributing to cobrapy.
+Thank you very much for contributing to cobrapy!
diff --git a/INSTALL.rst b/INSTALL.rst
index 3eba6cd..869902f 100644
--- a/INSTALL.rst
+++ b/INSTALL.rst
@@ -2,34 +2,34 @@ Installation of cobrapy
 =======================
 
 For installation help, please use the `Google
-Group <http://groups.google.com/group/cobra-pie>`__. For usage
+Group <http://groups.google.com/group/cobra-pie>`_. For usage
 instructions, please see the
-`documentation <https://cobrapy.readthedocs.org/en/latest/>`__.
-
---------------
+`documentation <https://cobrapy.readthedocs.org/en/latest/>`_.
 
 All releases require Python 2.7+ or 3.4+ to be installed before
 proceeding. Mac OS X (10.7+) and Ubuntu ship with Python. Windows users
 without python can download and install python from the `python
-website <https://www.python.org/ftp/python/2.7.9/python-2.7.9.amd64.msi>`__.
+website <https://www.python.org/ftp/python/2.7.9/python-2.7.9.amd64.msi>`_.
 Please note that though Anaconda and other python distributions may work
 with cobrapy, they are not explicitly supported (yet!).
 
 Stable version installation
----------------------------
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 cobrapy can be installed with any recent installation of pip.
 Instructions for several operating systems are below:
 
 Mac OS X or Linux
-~~~~~~~~~~~~~~~~~
+-----------------
 
 0. `install
-   pip <http://pip.readthedocs.org/en/latest/installing.html>`__.
+   pip <http://pip.readthedocs.org/en/latest/installing.html>`_.
 1. In a terminal, run ``sudo pip install cobra``
 
+We highly recommend updating ``pip`` beforehand (``pip install pip --upgrade``).
+
 Microsoft Windows
-~~~~~~~~~~~~~~~~~
+-----------------
 
 The preferred installation method on Windows is also to use pip. The
 latest Windows installers for Python 2.7 and 3.4 include pip, so if you
@@ -40,59 +40,40 @@ use those you will already have pip.
 
 To install without pip, you will need to download and use the
 appropriate installer for your version of python from the `python
-package index <https://pypi.python.org/pypi/cobra/>`__.
-
-Hacking version installation
-----------------------------
+package index <https://pypi.python.org/pypi/cobra/>`_.
 
-Use pip to install `Cython <http://cython.org/>`__. Install libglpk
-using your package manger. This would be
-``brew install homebrew/science/glpk`` on a Mac and
-``sudo apt-get install libglpk-dev`` on debian-based systems (including
-Ubuntu and Mint). GLPK can also be compiled from the released source.
+Installation for development
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-Clone the git repository using your preferred mothod. Cloning from your
-own `github fork <https://help.github.com/articles/fork-a-repo>`__ is
-recommended! Afterwards, open a terminal, enter the cobrapy repository
-and run the following command:
-
-::
-
-    python setup.py develop --user
+Get the `detailed contribution instructions <CONTRIBUTING.rst>`_ for contributing to cobrapy.
 
 Installation of optional dependencies
 =====================================
 
 Optional Dependencies
----------------------
+~~~~~~~~~~~~~~~~~~~~~
 
 On windows, these can downloaded from [this site]
 (http://www.lfd.uci.edu/~gohlke/pythonlibs/). On Mac/Linux, they can be
 installed using pip, or from the OS package manager (e.g brew, apt,
 yum).
 
-1. `libsbml <http://sbml.org>`__ >= 5.10 to read/write SBML level 2
+1. `libsbml <http://sbml.org>`_ >= 5.10 to read/write SBML level 2
    files
 
-   -  `Windows
-      installer <http://www.lfd.uci.edu/~gohlke/pythonlibs/#libsbml>`__
+   -  `Windows libsbml installer <http://www.lfd.uci.edu/~gohlke/pythonlibs/#libsbml>`_
    -  Use ``sudo pip install python-libsbml`` on Mac/Linux
 
-2. `lxml <http://lxml.de/>`__ to speed up read/write of SBML level 3
-   files.
-3. `numpy <http://numpy.org>`__ >= 1.6.1 for double deletions
-
-   -  `Windows
-      installer <http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy>`__
+2. `lxml <http://lxml.de/>`_ to speed up read/write of SBML level 3 files.
+3. `numpy <http://numpy.org>`_ >= 1.6.1 for double deletions
 
-4. `scipy <http://scipy.org>`__ >= 0.11 for ArrayBasedModel and saving
-   to \*.mat files.
+   -  `Windows numpy installer <http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy>`_
+4. `scipy <http://scipy.org>`_ >= 0.11 for ArrayBasedModel and saving to \*.mat files.
 
-   -  `Windows
-      installer <http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy>`__
+   -  `Windows scipy installer <http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy>`_
 
 Other solvers
--------------
+~~~~~~~~~~~~~
 
 cobrapy comes with bindings to the GNU Linear Programming Kit ([glpk]
 (http://www.gnu.org/software/glpk/)) using its own bindings called
@@ -100,16 +81,16 @@ cobrapy comes with bindings to the GNU Linear Programming Kit ([glpk]
 programming solvers:
 
 -  ILOG/CPLEX (available with
-   `Academic <https://www.ibm.com/developerworks/university/academicinitiative/>`__
+   `Academic <https://www.ibm.com/developerworks/university/academicinitiative/>`_
    and
-   `Commercial <http://www.ibm.com/software/integration/optimization/cplex-optimizer/>`__
+   `Commercial <http://www.ibm.com/software/integration/optimization/cplex-optimizer/>`_
    licenses).
--  `gurobi <http://gurobi.com>`__
+-  `gurobi <http://gurobi.com>`_
 -  `QSopt\_ex
-   esolver <http://www.dii.uchile.cl/~daespino/ESolver_doc/main.html>`__
--  `MOSEK <http://www.mosek.com/>`__
--  `coin-or clp and cbc <http://coin-or.org/>`__ through
-   `cylp <https://github.com/coin-or/CyLP>`__.
+   esolver <http://www.dii.uchile.cl/~daespino/ESolver_doc/main.html>`_
+-  `MOSEK <http://www.mosek.com/>`_
+-  `coin-or clp and cbc <http://coin-or.org/>`_ through
+   `cylp <https://github.com/coin-or/CyLP>`_.
 
 ILOG/CPLEX, MOSEK, and Gurobi are commercial software packages that
 currently provide free licenses for academics and support both linear
diff --git a/README.rst b/README.rst
index ec4e1d2..ba80cb4 100644
--- a/README.rst
+++ b/README.rst
@@ -1,34 +1,74 @@
-cobrapy
-=======
+cobrapy - constraint-based reconstruction and analysis in python
+================================================================
 
 |Build Status| |Coverage Status| |Build status| |PyPI| |Gitter|
 
-COnstraint-Based Reconstruction and Analysis (COBRA) methods are widely
-used for genome-scale modeling of metabolic networks in both prokaryotes
-and eukaryotes. COBRApy is a constraint-based modeling package that is
-designed to accommodate the biological complexity of the next generation
-of COBRA models and provides access to commonly used COBRA methods, such
-as flux balance analysis, flux variability analysis, and gene deletion
-analyses.
+What is cobrapy?
+~~~~~~~~~~~~~~~~
 
-To install, please follow the `instructions <INSTALL.md>`__.
+COBRA methods are widely used for genome-scale modeling of metabolic
+networks in both prokaryotes and eukaryotes. **cobrapy** is a
+constraint-based modeling package that is designed to accommodate the
+biological complexity of the next generation of COBRA models and
+provides access to commonly used COBRA methods, such as flux balance
+analysis, flux variability analysis, and gene deletion analyses.
+
+Our aim with cobrapy is to provide useful, efficient infrastructure
+for:
+
+- creating and managing metabolic models
+- accessing popular solvers
+- analyzing models with methods such as FVA, FBA, pFBA, MOMA etc. 
+- inspecting models and drawing conclusions on gene essentiality,
+  testing consequences of knock-outs etc.
+
+Our goal with cobrapy is for it to be useful on its own, and for it to
+be the natural choice of infrastructure for developers that want to
+build new COBRA related python packages for e.g. visualization,
+strain-design and data driven analysis. By re-using the same classes
+and design principles, we can make new methods both easier to
+implement and easier to use, thereby bringing the power of COBRA to
+more researchers.
 
 The documentation is browseable online at
-`readthedocs <https://cobrapy.readthedocs.org/en/stable/>`__ and can
+`readthedocs <https://cobrapy.readthedocs.org/en/stable/>`_ and can
 also be
-`downloaded <https://readthedocs.org/projects/cobrapy/downloads/>`__.
+`downloaded <https://readthedocs.org/projects/cobrapy/downloads/>`_.
 
 Please use the `Google
-Group <http://groups.google.com/group/cobra-pie>`__ for help.
+Group <http://groups.google.com/group/cobra-pie>`_ for help.
 Alternatively, you can use
-`gitter.im <https://gitter.im/opencobra/cobrapy>`__ for quick questions
+`gitter.im <https://gitter.im/opencobra/cobrapy>`_ for quick questions
 and discussions about cobrapy (faster response times).
 
 More information about opencobra is available at the
-`website <http://opencobra.github.io/>`__.
+`website <http://opencobra.github.io/>`_.
 
 If you use cobrapy in a scientific publication, please cite
-`doi:10.1186/1752-0509-7-74 <http://dx.doi.org/doi:10.1186/1752-0509-7-74>`__
+`doi:10.1186/1752-0509-7-74 <http://dx.doi.org/doi:10.1186/1752-0509-7-74>`_
+
+Installation
+~~~~~~~~~~~~
+
+Use pip to install cobrapy from
+`PyPI <https://pypi.python.org/pypi/cameo>`_ (we recommend doing this
+inside a `virtual
+environment <http://docs.python-guide.org/en/latest/dev/virtualenvs/>`_)::
+
+    pip install cobra
+
+In case you downloaded the source code, run::
+
+    pip install -e .
+
+In the ``cobrapy`` directory. For further information, please follow
+the `detailed installation instructions <INSTALL.rst>`_.
+
+Contributing
+~~~~~~~~~~~~
+
+Contributions are always welcome! Please read the `contributions
+guideline <CONTRIBUTING.rst>`_ to get started.
 
 License
 -------
@@ -52,10 +92,11 @@ Public License for more details.
 .. |Build Status| image:: https://travis-ci.org/opencobra/cobrapy.svg?branch=master
    :target: https://travis-ci.org/opencobra/cobrapy
 .. |Coverage Status| image:: https://codecov.io/github/opencobra/cobrapy/coverage.svg?branch=master
-   :target: https://codecov.io/github/opencobra/cobrapy/coverage.svg?branch=master
+   :target: https://codecov.io/github/opencobra/cobrapy
 .. |Build status| image:: https://ci.appveyor.com/api/projects/status/2o549lhjyukke8nd/branch/master?svg=true
-   :target: https://ci.appveyor.com/project/aebrahim/cobrapy/branch/master
+   :target: https://ci.appveyor.com/project/hredestig/cobrapy/branch/master
 .. |PyPI| image:: https://img.shields.io/pypi/v/cobra.svg
    :target: https://pypi.python.org/pypi/cobra
 .. |Gitter| image:: https://badges.gitter.im/opencobra/cobrapy.svg
    :target: https://gitter.im/opencobra/cobrapy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
+
diff --git a/cobra/VERSION b/cobra/VERSION
index 733fa3f..cb0c939 100644
--- a/cobra/VERSION
+++ b/cobra/VERSION
@@ -1 +1 @@
-0.5.0b2
+0.5.2
diff --git a/cobra/core/ArrayBasedModel.py b/cobra/core/ArrayBasedModel.py
index 71d463d..fdb722b 100644
--- a/cobra/core/ArrayBasedModel.py
+++ b/cobra/core/ArrayBasedModel.py
@@ -320,21 +320,20 @@ class LinkedArray(ndarray):
     def __setitem__(self, index, value):
         ndarray.__setitem__(self, index, value)
         if isinstance(index, slice):
-            for i, entry in enumerate(self._list[index]):
-                setattr(entry, self._attr, value)
+            # not sure why that is here
+            if index.stop == maxsize:
+                index = slice(index.start, len(self))
+            if hasattr(value, "__getitem__"):
+                for i, entry in enumerate(self._list[index]):
+                    setattr(entry, self._attr, value[i])
+            else:
+                for i, entry in enumerate(self._list[index]):
+                    setattr(entry, self._attr, value)
         else:
             setattr(self._list[index], self._attr, value)
 
     def __setslice__(self, i, j, value):
-        ndarray.__setitem__(self, slice(i, j), value)
-        if j == maxsize:
-            j = len(self)
-        if hasattr(value, "__getitem__"):  # setting to a list
-            for index in range(i, j):
-                setattr(self._list[index], self._attr, value[index])
-        else:
-            for index in range(i, j):
-                setattr(self._list[index], self._attr, value)
+        self.__setitem__(slice(i, j), value)
 
     def _extend(self, other):
         old_size = len(self)
diff --git a/cobra/flux_analysis/phenotype_phase_plane.py b/cobra/flux_analysis/phenotype_phase_plane.py
index 92e0333..37b3862 100644
--- a/cobra/flux_analysis/phenotype_phase_plane.py
+++ b/cobra/flux_analysis/phenotype_phase_plane.py
@@ -102,7 +102,7 @@ class phenotypePhasePlaneData:
         axes.set_ylabel(self.reaction2_name, size="x-large")
         axes.set_zlabel("Growth rate", size="x-large")
         axes.view_init(elev=30, azim=-135)
-        figure.tight_layout()
+        figure.set_tight_layout(True)
         return axes
 
     def plot_mayavi(self):
@@ -228,12 +228,15 @@ def calculate_phenotype_phase_plane(
     """calculates the growth rates while varying the uptake rates for two
     reactions.
 
-    returns: an object containing the growth rates for the uptake rates.
-    To plot the result, call the plot function of the returned object.
+    :returns: a `phenotypePhasePlaneData` object containing the growth rates
+    for the uptake rates. To plot the
+    result, call the plot function of the returned object.
 
-    Example:
-    data = calculate_phenotype_phase_plane(my_model, "EX_foo", "EX_bar")
-    data.plot()
+    :Example:
+    >>> import cobra.test
+    >>> model = cobra.test.create_test_model("textbook")
+    >>> ppp = calculate_phenotype_phase_plane(model, "EX_glc__D_e", "EX_o2_e")
+    >>> ppp.plot()
     """
     if solver is None:
         solver = get_solver_name()
diff --git a/cobra/flux_analysis/variability.py b/cobra/flux_analysis/variability.py
index ead05bf..fd93ad3 100644
--- a/cobra/flux_analysis/variability.py
+++ b/cobra/flux_analysis/variability.py
@@ -50,18 +50,17 @@ def flux_variability_analysis(cobra_model, reaction_list=None,
 def calculate_lp_variability(lp, solver, cobra_model, reaction_list,
                              **solver_args):
     """calculate max and min of selected variables in an LP"""
-    fva_results = {}
-    for r in reaction_list:
-        r_id = str(r)
-        i = cobra_model.reactions.index(r_id)
-        fva_results[r_id] = {}
-        solver.change_variable_objective(lp, i, 1.)
-        solver.solve_problem(lp, objective_sense="maximize", **solver_args)
-        fva_results[r_id]["maximum"] = solver.get_objective_value(lp)
-        solver.solve_problem(lp, objective_sense="minimize", **solver_args)
-        fva_results[r_id]["minimum"] = solver.get_objective_value(lp)
-        # revert the problem to how it was before
-        solver.change_variable_objective(lp, i, 0.)
+    fva_results = {str(r): {} for r in reaction_list}
+    for what in ("minimum", "maximum"):
+        sense = "minimize" if what == "minimum" else "maximize"
+        for r in reaction_list:
+            r_id = str(r)
+            i = cobra_model.reactions.index(r_id)
+            solver.change_variable_objective(lp, i, 1.)
+            solver.solve_problem(lp, objective_sense=sense, **solver_args)
+            fva_results[r_id][what] = solver.get_objective_value(lp)
+            # revert the problem to how it was before
+            solver.change_variable_objective(lp, i, 0.)
     return fva_results
 
 
diff --git a/cobra/test/data/textbook_solution.pickle b/cobra/test/data/textbook_solution.pickle
new file mode 100644
index 0000000..889ab38
Binary files /dev/null and b/cobra/test/data/textbook_solution.pickle differ
diff --git a/cobra/test/data/update_pickles.py b/cobra/test/data/update_pickles.py
index 807a27e..6225775 100755
--- a/cobra/test/data/update_pickles.py
+++ b/cobra/test/data/update_pickles.py
@@ -89,3 +89,8 @@ for key in sorted(fva_result):
     clean_result[key] = {k: round(v, 5) for k, v in fva_result[key].items()}
 with open("textbook_fva.json", "w") as outfile:
     json_dump(clean_result, outfile)
+
+# textbook solution
+cobra.flux_analysis.parsimonious.optimize_minimal_flux(textbook)
+with open('textbook_solution.pickle', 'wb') as f:
+    dump(textbook.solution, f, protocol=2)
diff --git a/cobra/test/flux_analysis.py b/cobra/test/flux_analysis.py
index ecaa3fe..8c081a2 100644
--- a/cobra/test/flux_analysis.py
+++ b/cobra/test/flux_analysis.py
@@ -6,6 +6,7 @@ from os.path import join
 from os import name
 from json import load
 from contextlib import contextmanager
+import pickle
 import re
 
 from six import iteritems, StringIO
@@ -22,6 +23,10 @@ try:
     import pandas
 except:
     pandas = None
+try:
+    import tabulate
+except:
+    tabulate = None
 
 if __name__ == "__main__":
     sys.path.insert(0, "../..")
@@ -335,14 +340,20 @@ class TestCobraFluxAnalysis(TestCase):
         for item in desired_entries:
             self.assertIn(re.sub('\s', '', item), output_set)
 
-    @skipIf(pandas is None, "summary methods require pandas")
+    @skipIf((pandas is None) or (tabulate is None),
+            "summary methods require pandas and tabulate")
     def test_summary_methods(self):
 
         # Test model summary methods
         model = create_test_model("textbook")
         with self.assertRaises(Exception):
             model.summary()
-        model.optimize()
+
+        # Load model solution
+        with open(join(data_directory, "textbook_solution.pickle"),
+                  "rb") as infile:
+            model.solution = pickle.load(infile)
+
         desired_entries = [
             'idFluxRangeidFluxRangeBiomass_Ecol...0.874',
             'o2_e       21.8   [19.9, 23.7]'
@@ -380,11 +391,13 @@ class TestCobraFluxAnalysis(TestCase):
         ]
         # Need to use a different method here because
         # there are multiple entries per line.
-        with captured_output() as (out, err):
-            model.summary()
-        s = out.getvalue()
-        for i in desired_entries:
-            self.assertIn(i, s)
+        for solver in solver_dict:
+            with captured_output() as (out, err):
+                model.summary()
+
+            s = out.getvalue()
+            for i in desired_entries:
+                self.assertIn(i, s)
 
         # Test metabolite summary methods
         desired_entries = [
@@ -398,9 +411,11 @@ class TestCobraFluxAnalysis(TestCase):
             '4.0 h_c + nadh_c + q8_c --> 3.0 h_e + nad_c + q...',
             '12%     5.06  SUCDi     q8_c + succ_c --> fum_c + q8h2_c',
         ]
-        with captured_output() as (out, err):
-            model.metabolites.q8_c.summary()
-        self.check_entries(out, desired_entries)
+
+        for solver in solver_dict:
+            with captured_output() as (out, err):
+                model.metabolites.q8_c.summary()
+            self.check_entries(out, desired_entries)
 
         desired_entries = [
             'PRODUCING REACTIONS -- D-Fructose 1,6-bisphosphate (fdp_c)',
@@ -415,6 +430,7 @@ class TestCobraFluxAnalysis(TestCase):
             '0%      0     [0, 1.72]     FBP       '
             'fdp_c + h2o_c --> f6p_c + pi_c',
         ]
+
         for solver in solver_dict:
             with captured_output() as (out, err):
                 model.metabolites.fdp_c.summary(fva=0.99, solver=solver)
diff --git a/cobra/test/unit_tests.py b/cobra/test/unit_tests.py
index 23213f7..fdd583b 100644
--- a/cobra/test/unit_tests.py
+++ b/cobra/test/unit_tests.py
@@ -289,7 +289,6 @@ class TestReactions(CobraTestCase):
         model = self.model
         reaction = model.reactions.get_by_id("PGI")
         old_gene = list(reaction.genes)[0]
-        old_gene_reaction_rule = reaction.gene_reaction_rule
         new_gene = model.genes.get_by_id("s0001")
         # add an existing 'gene' to the gpr
         reaction.gene_reaction_rule = 's0001'
@@ -779,6 +778,21 @@ class TestCobraArrayModel(TestCobraModel):
         with self.assertRaises(TypeError):
             model.reactions[[True, False]]
 
+    def test_array_based_bounds_setting(self):
+        model = self.model
+        bounds = [0.0] * len(model.reactions)
+        model.lower_bounds = bounds
+        self.assertEqual(type(model.reactions[0].lower_bound), float)
+        self.assertAlmostEqual(model.reactions[0].lower_bound, 0.0)
+        model.upper_bounds[1] = 1234.0
+        self.assertAlmostEqual(model.reactions[1].upper_bound, 1234.0)
+        model.upper_bounds[9:11] = [100.0, 200.0]
+        self.assertAlmostEqual(model.reactions[9].upper_bound, 100.0)
+        self.assertAlmostEqual(model.reactions[10].upper_bound, 200.0)
+        model.upper_bounds[9:11] = 123.0
+        self.assertAlmostEqual(model.reactions[9].upper_bound, 123.0)
+        self.assertAlmostEqual(model.reactions[10].upper_bound, 123.0)
+
 
 # make a test suite to run all of the tests
 loader = TestLoader()
diff --git a/config.sh b/config.sh
index f1bfd61..b8ba8a7 100644
--- a/config.sh
+++ b/config.sh
@@ -7,25 +7,26 @@ function pre_build {
     if [ -n "$IS_OSX" ]; then
         export CC=clang
         export CXX=clang++
-		export CFLAGS="-fPIC -O3 -arch i386 -arch x86_64 -g -DNDEBUG -mmacosx-version-min=10.6"
-	else
-		yum install -y libxslt libxml2 libxml2-devel libxslt-devel
-	fi
-	curl -O http://ftp.gnu.org/gnu/glpk/glpk-4.60.tar.gz
-	tar xzf glpk-4.60.tar.gz
-	(cd glpk-4.60 \
-			&& ./configure \
-			&& make \
-			&& make install)
-	pip install cython
-	cython -a cobra/solvers/cglpk.pyx
-	export PATH="$PATH:/usr/local/bin"
+        export CFLAGS="-fPIC -O3 -arch i386 -arch x86_64 -g -DNDEBUG -mmacosx-version-min=10.6"
+    else
+        yum install -y libxslt libxml2 libxml2-devel libxslt-devel
+    fi
+    curl -O http://ftp.gnu.org/gnu/glpk/glpk-4.60.tar.gz
+    tar xzf glpk-4.60.tar.gz
+    (cd glpk-4.60 \
+            && ./configure \
+            && make \
+            && make install)
+    pip install cython
+    cython -a cobra/solvers/cglpk.pyx
+    export PATH="$PATH:/usr/local/bin"
 }
 
 function build_wheel {
     # Set default building method to pip
     build_bdist_wheel $@
-	(cd glpk-4.60 && make uninstall)
+	# avoid this for now, (we get broken linux wheels due to https://github.com/pypa/manylinux/issues/80, but testing works)
+	#(cd glpk-4.60 && make uninstall)
 }
 
 function run_tests_in_repo {
diff --git a/develop-requirements.txt b/develop-requirements.txt
new file mode 100644
index 0000000..f72cca2
--- /dev/null
+++ b/develop-requirements.txt
@@ -0,0 +1,15 @@
+# Requirements for developing cobrapy
+six
+Cython>=0.21
+numpy>=1.6
+scipy>=0.11.0
+python-libsbml
+lxml
+matplotlib
+palettable
+zmq
+pymatbridge
+pandas>=0.17.0
+tabulate
+tox
+pep8
diff --git a/documentation_builder/faq.ipynb b/documentation_builder/faq.ipynb
index 4f6188c..9fdde88 100644
--- a/documentation_builder/faq.ipynb
+++ b/documentation_builder/faq.ipynb
@@ -25,7 +25,7 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "Please see the [INSTALL.md](https://github.com/opencobra/cobrapy/blob/master/INSTALL.md) file."
+    "Please see the [INSTALL.rst](https://github.com/opencobra/cobrapy/blob/master/INSTALL.rst) file."
    ]
   },
   {
diff --git a/documentation_builder/index.rst b/documentation_builder/index.rst
index ced5671..40523f9 100644
--- a/documentation_builder/index.rst
+++ b/documentation_builder/index.rst
@@ -1,7 +1,7 @@
 Documentation for COBRApy
 =========================
-For installation instructions, please see `INSTALL.md
-<https://github.com/opencobra/cobrapy/blob/master/INSTALL.md>`_.
+For installation instructions, please see `INSTALL.rst
+<https://github.com/opencobra/cobrapy/blob/master/INSTALL.rst>`_.
 
 Many of the examples below are viewable as IPython notebooks, which can
 be viewed at `nbviewer
@@ -33,4 +33,3 @@ Indices and tables
 * :ref:`genindex`
 * :ref:`modindex`
 * :ref:`search`
-
diff --git a/make-mac-wheels.sh b/make-mac-wheels.sh
new file mode 100755
index 0000000..cf1da29
--- /dev/null
+++ b/make-mac-wheels.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -e
+
+for PYBIN in /Library/Frameworks/Python.framework/Versions/*/bin; do
+	${PYBIN}/pip install wheel delocate
+    ${PYBIN}/python setup.py bdist_wheel
+done
+
+# Bundle external shared libraries into the wheels
+for whl in dist/cobra*.whl; do
+    delocate-wheel $whl -w dist/wheelhouse/
+done
+
diff --git a/manylinux_builder/build_cobrapy.sh b/manylinux_builder/build_cobrapy.sh
index 6703649..8552aa8 100755
--- a/manylinux_builder/build_cobrapy.sh
+++ b/manylinux_builder/build_cobrapy.sh
@@ -1,6 +1,7 @@
 #!/bin/bash
 
 for PYBIN in /opt/python/*/bin; do
+    ${PYBIN}/pip install pyelftools==0.23
     ${PYBIN}/pip wheel cobra --pre
 done
 
diff --git a/scripts/deploy.sh b/scripts/deploy.sh
index 10d6876..fe46af5 100755
--- a/scripts/deploy.sh
+++ b/scripts/deploy.sh
@@ -2,4 +2,5 @@
 echo -e " ... running twine to deploy ... "
 pip install twine
 
-twine upload --skip-existing --username "${PYPI_USERNAME}" --password "${PYPI_PASSWORD}" ${TRAVIS_BUILD_DIR}/wheelhouse/*
+# only upload mac wheels for now, linux wheels are broken due to https://github.com/pypa/manylinux/issues/80
+twine upload --skip-existing --username "${PYPI_USERNAME}" --password "${PYPI_PASSWORD}" ${TRAVIS_BUILD_DIR}/wheelhouse/*macosx*.whl
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..6c4f934
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,12 @@
+[tox]
+envlist = pep8, py27, py35
+
+[testenv:pep8]
+basepython=python
+deps=pep8
+commands=pep8 cobra --exclude=oven,solvers,sbml.py
+
+[testenv]
+commands =
+    pip install -U pip
+    python setup.py test

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python-cobra.git



More information about the debian-med-commit mailing list