Skip to content

Commit

Permalink
Release 0.11.22
Browse files Browse the repository at this point in the history
Merge pull request #1601 from AMICI-dev/release/0.12.0
  • Loading branch information
dweindl authored Dec 2, 2021
2 parents 82d2cbb + 2c83043 commit 3a7c28e
Show file tree
Hide file tree
Showing 11 changed files with 466 additions and 2,175 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

## v0.X Series

### v0.11.22 (2021-12-02)

* **Require sympy>=1.9,pysb>=1.13.1** by @FFroehlich, @dweindl
in https://github.com/AMICI-dev/AMICI/pull/1599
* Fixed sympy deprecation warning by @dweindl in
https://github.com/AMICI-dev/AMICI/pull/1600
* Updated Windows installation instructions for Python>=3.8 by @dweindl
in https://github.com/AMICI-dev/AMICI/pull/1597
* Fixed plot labels by @dweindl in https://github.com/AMICI-dev/AMICI/pull/1598

**Full Changelog**:
https://github.com/AMICI-dev/AMICI/compare/v0.11.21...v0.11.22

### v0.11.21 (2021-11-21)

Fixes:
Expand Down
12 changes: 12 additions & 0 deletions documentation/python_installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,18 @@ by MSVC (see Visual Studio above). ``KERNEL32.dll`` is part of Windows and in
``C:\Windows\System32``. The ``api-ms-win-crt-XXX-l1-1-0.dll`` are needed by
``openblas.dll`` and are part of the Windows Universal C Runtime.
.. note::
Since Python 3.8, the library directory needs to be set as follows:
.. code-block:: python
import os
# directory containing `openblas.dll`
os.add_dll_directory("C:\\BLAS\\bin")
import amici
Adding it to ``PATH`` will not work.
Further topics
++++++++++++++
Expand Down
3 changes: 3 additions & 0 deletions include/amici/solver.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class Solver {
/** Type of what is passed to Sundials solvers as user_data */
using user_data_type = std::pair<Model *, Solver const*>;

/**
* @brief Default constructor
*/
Solver() = default;

/**
Expand Down
2 changes: 1 addition & 1 deletion include/amici/symbolic_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace amici {

double log(double x);
double dirac(double x);
double heaviside(double x);
double heaviside(double x, double x0);

double min(double a, double b, double c);
double Dmin(int id, double a, double b, double c);
Expand Down
28 changes: 11 additions & 17 deletions python/amici/ode_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,11 +845,9 @@ def smart_is_zero_matrix(x: Union[sp.MutableDenseMatrix,
"""

if isinstance(x, sp.MutableDenseMatrix):
nonzero = any(xx.is_zero is not True for xx in x._mat)
else:
nonzero = x.nnz() > 0
return all(xx.is_zero is True for xx in x.flat())

return not nonzero
return x.nnz() == 0


class ODEModel:
Expand Down Expand Up @@ -1626,7 +1624,7 @@ def parse_events(self) -> None:
expr.set_val(self._process_heavisides(expr.get_val(), roots))

# remove all possible Heavisides from roots, which may arise from
# the substitution of `'w'` in `_collect_heaviside_roots`
# the substitution of `'w'` in `_get_unique_root`
for root in roots:
root.set_val(self._process_heavisides(root.get_val(), roots))

Expand Down Expand Up @@ -2354,6 +2352,14 @@ def _get_unique_root(
unique identifier for root, or `None` if the root is not
time-dependent
"""
# substitute 'w' expressions into root expressions now, to avoid
# rewriting '{model_name}_root.cpp' and '{model_name}_stau.cpp' headers
# to include 'w.h'
w_sorted = toposort_symbols(dict(zip(
[expr.get_id() for expr in self._expressions],
[expr.get_val() for expr in self._expressions],
)))
root_found = root_found.subs(w_sorted)

if not self._expr_is_time_dependent(root_found):
return None
Expand Down Expand Up @@ -2395,18 +2401,6 @@ def _collect_heaviside_roots(
elif arg.has(sp.Heaviside):
root_funs.extend(self._collect_heaviside_roots(arg.args))

# substitute 'w' expressions into root expressions now, to avoid
# rewriting '{model_name}_root.cpp' and '{model_name}_stau.cpp' headers
# to include 'w.h'
w_sorted = toposort_symbols(dict(zip(
[expr.get_id() for expr in self._expressions],
[expr.get_val() for expr in self._expressions],
)))
root_funs = [
r.subs(w_sorted)
for r in root_funs
]

return root_funs

def _process_heavisides(
Expand Down
29 changes: 15 additions & 14 deletions python/amici/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from matplotlib.axes import Axes
from typing import Optional, Iterable


def plotStateTrajectories(
rdata: ReturnDataView,
state_indices: Optional[Iterable[int]] = None,
Expand All @@ -27,7 +28,7 @@ def plotStateTrajectories(
:param ax:
matplotlib Axes instance to plot into
:param model:
amici model instance
"""
Expand All @@ -37,18 +38,18 @@ def plotStateTrajectories(
state_indices = range(rdata['x'].shape[1])
for ix in state_indices:
if model is None:
label = f'x_{ix}'
elif model.getStateNames()[ix] != '':
label = f'$x_{{{ix}}}$'
elif model.getStateNames()[ix]:
label = model.getStateNames()[ix]
else:
label = model.getStateIds()[ix]
ax.plot(rdata['t'], rdata['x'][:, ix], label = label)
ax.set_xlabel('$t$ (s)')
ax.set_ylabel('$x_i(t)$ (mmol/ml)')
ax.plot(rdata['t'], rdata['x'][:, ix], label=label)
ax.set_xlabel('$t$')
ax.set_ylabel('$x(t)$')
ax.legend()
ax.set_title('State trajectories')


def plotObservableTrajectories(
rdata: ReturnDataView,
observable_indices: Optional[Iterable[int]] = None,
Expand Down Expand Up @@ -77,13 +78,13 @@ def plotObservableTrajectories(
observable_indices = range(rdata['y'].shape[1])
for iy in observable_indices:
if model is None:
label = f'y_{iy}'
elif model.getObservableNames()[iy] != '':
label = f'$y_{{{iy}}}$'
elif model.getObservableNames()[iy]:
label = model.getObservableNames()[iy]
else:
label = model.getObservableIds()[iy]
ax.plot(rdata['t'], rdata['y'][:, iy], label = label)
ax.set_xlabel('$t$ (s)')
ax.set_ylabel('$y_i(t)$ (AU)')
ax.plot(rdata['t'], rdata['y'][:, iy], label=label)
ax.set_xlabel('$t$')
ax.set_ylabel('$y(t)$')
ax.legend()
ax.set_title('Observables')
ax.set_title('Observable trajectories')
Loading

0 comments on commit 3a7c28e

Please sign in to comment.