Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into binder_landing
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl committed Jan 17, 2023
2 parents edd9494 + b58a005 commit 265f128
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 42 deletions.
2 changes: 2 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ build:
# for custom doxygen
- libclang-cpp9
- libclang1-9
- libatlas-base-dev
- swig
tools:
python: "3.8"
59 changes: 21 additions & 38 deletions documentation/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,43 +84,6 @@ def install_mtocpp():
raise RuntimeError('downloadAndBuildMtocpp.sh failed')


def install_amici_deps_rtd():
"""Install AMICI dependencies and set up environment for use on RTD"""

# cblas -- manually install ubuntu deb package
cblas_root = os.path.join(amici_dir, 'ThirdParty', 'libatlas-base-dev',
'usr')

if os.path.isdir(cblas_root):
# If this exists, it means this has been run before. On RTD, sphinx is
# being run several times and we don't want to reinstall dependencies
# every time.
return

cblas_inc_dir = os.path.join(cblas_root, "include", "x86_64-linux-gnu")
cblas_lib_dir = os.path.join(cblas_root, "lib", "x86_64-linux-gnu")
cmd = (f"cd '{os.path.join(amici_dir, 'ThirdParty')}' "
"&& apt download libatlas-base-dev && mkdir libatlas-base-dev "
"&& cd libatlas-base-dev "
"&& ar x ../libatlas-base-dev_3.10.3-8ubuntu7_amd64.deb "
"&& tar -xJf data.tar.xz "
f"&& ln -s {cblas_inc_dir}/cblas-atlas.h {cblas_inc_dir}/cblas.h "
)
subprocess.run(cmd, shell=True, check=True)
os.environ['BLAS_CFLAGS'] = f'-I{cblas_inc_dir}'
os.environ['BLAS_LIBS'] = (f'-L{cblas_lib_dir}/atlas -L{cblas_lib_dir} '
'-lcblas -latlas -lblas -lm')

# build swig4.0
subprocess.run(os.path.join(amici_dir, 'scripts',
'downloadAndBuildSwig.sh'), check=True)

# add swig to path
swig_dir = os.path.join(amici_dir, 'ThirdParty', 'swig-4.0.2', 'install',
'bin')
os.environ['SWIG'] = os.path.join(swig_dir, 'swig')


def install_doxygen():
"""Get a more recent doxygen"""
version = '1.9.6'
Expand Down Expand Up @@ -156,7 +119,6 @@ def install_doxygen():

# only execute those commands when running from RTD
if 'READTHEDOCS' in os.environ and os.environ['READTHEDOCS']:
install_amici_deps_rtd()
install_doxygen()

# Required for matlab doxygen processing
Expand Down Expand Up @@ -248,6 +210,27 @@ def install_doxygen():
'python': ('https://docs.python.org/3', None),
}

# Add notebooks prolog with binder links
# get current git reference
ret = subprocess.run(
"git rev-parse HEAD".split(" "),
capture_output=True
)
ref = ret.stdout.rstrip().decode()
nbsphinx_prolog = (
f"{{% set {ref=} %}}"
r"""
{% set docname = "documentation/" + env.doc2path(env.docname, base=False) %}
.. raw:: html
<div class="note">
<a href="https://mybinder.org/v2/gh/AMICI-dev/AMICI/{{ ref|e }}?labpath={{ docname|e }}" target="_blank">
<img src="https://mybinder.org/badge_logo.svg" alt="Open in binder"/></a>
</div>
"""
)

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

Expand Down
26 changes: 22 additions & 4 deletions python/sdist/amici/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
--------
Plotting related functions
"""
from . import ReturnDataView, Model
from typing import Iterable, Optional

import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from matplotlib.axes import Axes
from typing import Optional, Iterable

from . import Model, ReturnDataView

def plotStateTrajectories(

def plot_state_trajectories(
rdata: ReturnDataView,
state_indices: Optional[Iterable[int]] = None,
ax: Optional[Axes] = None,
Expand Down Expand Up @@ -50,7 +53,7 @@ def plotStateTrajectories(
ax.set_title('State trajectories')


def plotObservableTrajectories(
def plot_observable_trajectories(
rdata: ReturnDataView,
observable_indices: Optional[Iterable[int]] = None,
ax: Optional[Axes] = None,
Expand Down Expand Up @@ -88,3 +91,18 @@ def plotObservableTrajectories(
ax.set_ylabel('$y(t)$')
ax.legend()
ax.set_title('Observable trajectories')


def plot_jacobian(rdata: ReturnDataView):
"""Plot Jacobian as heatmap."""
df = pd.DataFrame(
data=rdata.J,
index=rdata._swigptr.state_ids,
columns=rdata._swigptr.state_ids
)
sns.heatmap(df, center=0.0)
plt.title("Jacobian")

# backwards compatibility
plotStateTrajectories = plot_state_trajectories
plotObservableTrajectories = plot_observable_trajectories

0 comments on commit 265f128

Please sign in to comment.