Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl committed Mar 26, 2024
1 parent c6528c4 commit 6ee03be
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 8 deletions.
1 change: 1 addition & 0 deletions include/amici/serialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ void serialize(Archive& ar, amici::Model& m, unsigned int const /*version*/) {
ar & m.steadystate_computation_mode_;
ar & m.steadystate_sensitivity_mode_;
ar & m.state_independent_events_;
ar & m.steadystate_mask_;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions include/amici/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ inline span<realtype> make_span(N_Vector nv) {
}

/**
* @brief Create span from N_Vector
* @param nv
* @brief Create span from AmiVector
* @param av
*
*/
inline span<realtype const> make_span(amici::AmiVector const& av) {
Expand Down
1 change: 1 addition & 0 deletions python/sdist/amici/swig_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ def writeSolverSettingsToHDF5(
"SteadyStateSensitivityMode",
("t0", "setT0"),
"Timepoints",
"_steadystate_mask",
]


Expand Down
6 changes: 5 additions & 1 deletion python/tests/test_preequilibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
from amici.debugging import get_model_for_preeq
from numpy.testing import assert_allclose, assert_equal
from test_pysb import get_data
from amici.testing import TemporaryDirectoryWinSafe as TemporaryDirectory
from amici.testing import (
TemporaryDirectoryWinSafe as TemporaryDirectory,
skip_on_valgrind,
)


@pytest.fixture
Expand Down Expand Up @@ -661,6 +664,7 @@ def test_get_model_for_preeq(preeq_fixture):
)


@skip_on_valgrind
def test_partial_eq():
"""Check that partial equilibration is possible."""
from amici.antimony_import import antimony2amici
Expand Down
14 changes: 10 additions & 4 deletions python/tests/test_swig_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_copy_constructors(pysb_example_presimulation_module):
val = get_val(obj, attr)

try:
modval = get_mod_val(val, attr)
modval = get_mod_val(val, attr, obj)
except ValueError:
# happens for everything that is not bool or scalar
continue
Expand Down Expand Up @@ -79,6 +79,10 @@ def test_copy_constructors(pysb_example_presimulation_module):
tuple([1.0] + [0.0] * 35),
tuple([0.1] * 36),
],
"_steadystate_mask": [
(),
tuple([0] * 3),
],
"MinimumSigmaResiduals": [
50.0,
60.0,
Expand Down Expand Up @@ -361,19 +365,21 @@ def get_val(obj, attr):
return getattr(obj, attr)


def get_mod_val(val, attr):
def get_mod_val(val, attr, obj):
if attr == "getReturnDataReportingMode":
return amici.RDataReporting.likelihood
elif attr == "getParameterList":
return tuple(get_mod_val(val[0], "") for _ in val)
return tuple(get_mod_val(val[0], "", obj) for _ in val)
elif attr == "getStateIsNonNegative":
raise ValueError("Cannot modify value")
elif attr == "get_steadystate_mask":
return [0 for _ in range(obj.nx_solver)]
elif isinstance(val, bool):
return not val
elif isinstance(val, numbers.Number):
return val + 1
elif isinstance(val, tuple):
return tuple(get_mod_val(v, attr) for v in val)
return tuple(get_mod_val(v, attr, obj) for v in val)

raise ValueError("Cannot modify value")

Expand Down
6 changes: 6 additions & 0 deletions src/hdf5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,12 @@ void readModelDataFromHDF5(
model.setInitialStates(x0);
}

if (locationExists(file, datasetPath + "/steadystate_mask")) {
auto mask = getDoubleDataset1D(file, datasetPath + "/steadystate_mask");
if (!mask.empty())
model.set_steadystate_mask(mask);
}

if (locationExists(file, datasetPath + "/sx0")) {
hsize_t length0 = 0;
hsize_t length1 = 0;
Expand Down
4 changes: 3 additions & 1 deletion src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ bool operator==(Model const& a, Model const& b) {
&& (a.nmaxevent_ == b.nmaxevent_)
&& (a.state_is_non_negative_ == b.state_is_non_negative_)
&& (a.sigma_res_ == b.sigma_res_) && (a.min_sigma_ == b.min_sigma_)
&& a.state_ == b.state_;
&& (a.state_ == b.state_)
&& (a.steadystate_mask_.getVector()
== b.steadystate_mask_.getVector());
}

bool operator==(ModelDimensions const& a, ModelDimensions const& b) {
Expand Down
1 change: 1 addition & 0 deletions swig/model.i
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ using namespace amici;
%ignore fdx_rdatadtcl;
%ignore fdx_rdatadx_solver;
%ignore fdsigmaydy;
%ignore get_steadystate_mask_av;

%newobject amici::Model::clone;

Expand Down

0 comments on commit 6ee03be

Please sign in to comment.