Skip to content

Commit

Permalink
Merge pull request #1827 from AMICI-dev/release_0.11.31
Browse files Browse the repository at this point in the history
Release 0.11.31
  • Loading branch information
dweindl authored Jul 12, 2022
2 parents 650c23d + d4229fc commit 7bc909b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## v0.X Series

### v0.11.31 (2022-07-12)

Fixes:
* Fixed `ParameterMapping.__getitem__` to either return a
`ParameterMappingForCondition` or a new `ParameterMapping`, but not a list
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/1826

### v0.11.30 (2022-07-07)

Features:
Expand Down
11 changes: 8 additions & 3 deletions python/amici/parameter_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
for usage together with PEtab, for which the whole workflow of generating
the mapping is automatized.
"""

from __future__ import annotations

import numbers
import warnings
Expand Down Expand Up @@ -136,8 +136,13 @@ def __init__(
def __iter__(self):
yield from self.parameter_mappings

def __getitem__(self, item):
return self.parameter_mappings[item]
def __getitem__(
self, item
) -> Union[ParameterMapping, ParameterMappingForCondition]:
result = self.parameter_mappings[item]
if isinstance(result, ParameterMappingForCondition):
return result
return ParameterMapping(result)

def __len__(self):
return len(self.parameter_mappings)
Expand Down
3 changes: 3 additions & 0 deletions python/tests/test_parameter_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ def test_parameter_mapping():
parameter_mapping.append(par_map_for_condition)

assert len(parameter_mapping) == 1

assert isinstance(parameter_mapping[0], ParameterMappingForCondition)
assert isinstance(parameter_mapping[:], ParameterMapping)
18 changes: 6 additions & 12 deletions tests/benchmark-models/test_petab_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"""
Simulate a PEtab problem and compare results to reference values
"""

import argparse
import contextlib
import importlib
import logging
import os
Expand All @@ -15,7 +15,7 @@
from amici.logging import get_logger
from amici.petab_objective import (simulate_petab, rdatas_to_measurement_df,
LLH, RDATAS)
from petab.visualize import plot_petab_problem
from petab.visualize import plot_problem

logger = get_logger(f"amici.{__name__}", logging.WARNING)

Expand Down Expand Up @@ -56,9 +56,7 @@ def parse_cli_args():
help='File to write simulation result to, in PEtab'
'measurement table format.')

args = parser.parse_args()

return args
return parser.parse_args()


def main():
Expand Down Expand Up @@ -103,21 +101,17 @@ def main():
sim_df.to_csv(index=False, sep="\t")

if args.plot:
try:
with contextlib.suppress(NotImplementedError):
# visualize fit
axs = plot_petab_problem(petab_problem=problem, sim_data=sim_df)
axs = plot_problem(petab_problem=problem, simulations_df=sim_df)

# save figure
for plot_id, ax in axs.items():
fig_path = os.path.join(args.model_directory,
args.model_name + "_" + plot_id
+ "_vis.png")
f"{args.model_name}_{plot_id}_vis.png")
logger.info(f"Saving figure to {fig_path}")
ax.get_figure().savefig(fig_path, dpi=150)

except NotImplementedError:
pass

if args.check:
references_yaml = os.path.join(os.path.dirname(__file__),
"benchmark_models.yaml")
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.30
0.11.31

0 comments on commit 7bc909b

Please sign in to comment.