Skip to content

Commit

Permalink
doc(python) Extend steadystate python-interface example | ci(python) F…
Browse files Browse the repository at this point in the history
…ixes #348 (#349)

* doc(python) Extend steadystate python-interface example

* feature(python) Add basic plotting functions

* ci(python) python3 instead of python3.6

* ci() Disallow failure on osx; update python path

* doc(python) make doxygen compatible

* ci(osx) add tex path
  • Loading branch information
dweindl authored Jul 13, 2018
1 parent 17b29a0 commit acb0375
Show file tree
Hide file tree
Showing 5 changed files with 1,194 additions and 212 deletions.
24 changes: 1 addition & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,35 +52,13 @@ matrix:
on:
branch: master

allow_failures:
# allow osx build to fail until symengine/homebrew/python3.7 issue is resolved
- os: osx
osx_image: xcode9.3
compiler: clang
before_install:
- brew update # without this homebrew can stumble over wrong ruby version
- travis_wait brew install gcc || brew link --overwrite gcc # fix linker warning regarding /usr/local/include/c++
- brew install hdf5 cppcheck swig doxygen ragel graphviz homebrew/cask/mactex
- brew upgrade python
after_success:
- cd $BASE_DIR # cd to base dir for correct relative path in deploy
deploy:
provider: pages
local-dir: doc
skip-cleanup: true
github-token: $GITHUB_TOKEN # Set in the settings page of your repository, as a secure variable
keep-history: false
verbose: true
on:
branch: master

install:
# Python distutils only looks for `swig` and does not find `swig3.0`
- export BASE_DIR=`pwd`
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mkdir -p ~/bin/ && ln -s /usr/bin/swig3.0 ~/bin/swig && export PATH=~/bin/:$PATH; fi
- pyenv versions
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then pyenv shell 2.7 3.6; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH=/Users/travis/Library/Python/3.6/bin:$PATH; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH=/Users/travis/Library/Python/3.7/bin:/Library/TeX/texbin:$PATH; fi
- pip3 install --user --upgrade pip setuptools wheel pkgconfig doxypypy coverage scipy
- ./scripts/buildSuiteSparse.sh
- ./scripts/buildSundials.sh
Expand Down
52 changes: 52 additions & 0 deletions python/amici/plotting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""@package amici.plotting Plotting related functions"""

import matplotlib.pyplot as plt

def plotStateTrajectories(rdata, state_indices=None, ax = None):
"""Plot state trajectories
Arguments:
rdata: AMICI simulation results as returned by amici.getSimulationResults()
state_indices: Indices of states for which trajectories are to be plotted
ax: matplotlib.axes.Axes instance to plot into
Returns:
Raises:
"""
if not ax:
fig, ax = plt.subplots()
if not state_indices:
state_indices = range(rdata['x'].shape[1])
for ix in state_indices:
ax.plot(rdata['t'], rdata['x'][:, ix], label='$x_%d$' % ix)
ax.set_xlabel('$t$ (s)')
ax.set_ylabel('$x_i(t)$ (mmol/ml)')
ax.legend()
ax.set_title('State trajectories')


def plotObservableTrajectories(rdata, observable_indices=None, ax = None):
"""Plot observable trajectories
Arguments:
rdata: AMICI simulation results as returned by amici.getSimulationResults()
observable_indices: Indices of observables for which trajectories are to be plotted
ax: matplotlib.axes.Axes instance to plot into
Returns:
Raises:
"""
if not ax:
fig, ax = plt.subplots()
if not observable_indices:
observable_indices = range(rdata['y'].shape[1])
for iy in observable_indices:
ax.plot(rdata['t'], rdata['y'][:, iy], label='$y_%d$' % iy)
ax.set_xlabel('$t$ (s)')
ax.set_ylabel('$y_i(t)$ (AU)')
ax.legend()
ax.set_title('Observables')
Loading

0 comments on commit acb0375

Please sign in to comment.