Skip to content

Commit

Permalink
Rewrite of summary methods (#271)
Browse files Browse the repository at this point in the history
This commit implements a rewrite of the flux summary methods, using
tabulate to align and print the majority of the text. These updates fix
some lingering issues with the summary methods and will hopefully make
maintainence easier in the long term.
  • Loading branch information
pstjohn authored and hredestig committed Aug 30, 2016
1 parent 9650105 commit 20d3de8
Show file tree
Hide file tree
Showing 6 changed files with 237 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ env:
before_install:
- pip install pip --upgrade
# These get cached
- pip install numpy scipy python-libsbml cython coveralls jsonschema six matplotlib pandas
- pip install numpy scipy python-libsbml cython coveralls jsonschema six matplotlib pandas tabulate
- 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
Expand Down
5 changes: 4 additions & 1 deletion cobra/core/Metabolite.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,15 @@ def summary(self, **kwargs):
If given, fva should be a float between 0 and 1, representing the
fraction of the optimum objective to be searched.
floatfmt: string
format method for floats, passed to tabulate. Default is '.3g'.
"""
try:
from ..flux_analysis.summary import metabolite_summary
return metabolite_summary(self, **kwargs)
except ImportError:
warn('Summary methods require pandas')
warn('Summary methods require pandas/tabulate')

elements_and_molecular_weights = {
'H': 1.007940,
Expand Down
8 changes: 5 additions & 3 deletions cobra/core/Model.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,16 +364,18 @@ def summary(self, **kwargs):
threshold: float
tolerance for determining if a flux is zero (not printed)
fva: int or None
Whether or not to calculate and report flux variability in the
output summary
round: int
number of digits after the decimal place to print
floatfmt: string
format method for floats, passed to tabulate. Default is '.3g'.
"""

try:
from ..flux_analysis.summary import model_summary
return model_summary(self, **kwargs)
except ImportError:
warn('Summary methods require pandas')
warn('Summary methods require pandas/tabulate')

0 comments on commit 20d3de8

Please sign in to comment.