Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError for parameter with amici prefix #1418

Open
matthiaskoenig opened this issue Jun 18, 2024 · 2 comments
Open

KeyError for parameter with amici prefix #1418

matthiaskoenig opened this issue Jun 18, 2024 · 2 comments
Assignees
Labels
AMICI bug Something isn't working

Comments

@matthiaskoenig
Copy link

Hi all,
it seems there are some issues with the amici prefixes on parameters. Example attached.
I am trying to import a petab problem, but the importer fails with a KeyError.
amici_k.zip

import petab
from pathlib import Path
import pypesto.petab
from petabunit.console import console
import logging

console.rule("Load PEtab", style="white")
petab_yaml: Path = Path(__file__).parent / "simple_pk.yaml"
petab_problem = petab.Problem.from_yaml(petab_yaml)
importer = pypesto.petab.PetabImporter(petab_problem)
problem = importer.create_problem(verbose=True)
/home/mkoenig/.virtualenvs/petabunit/lib/python3.12/site-packages/pypesto/petab/importer.py:487: RuntimeWarning: The following problem parameters were not used: {'k'}
  amici.petab.conditions.fill_in_parameters(
Traceback (most recent call last):
  File "/home/mkoenig/git/petabunit/examples/simple_pk/simple_pk_optimization.py", line 13, in <module>
    problem = importer.create_problem(verbose=True)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mkoenig/.virtualenvs/petabunit/lib/python3.12/site-packages/pypesto/petab/importer.py", line 735, in create_problem
    objective = self.create_objective(**kwargs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mkoenig/.virtualenvs/petabunit/lib/python3.12/site-packages/pypesto/petab/importer.py", line 487, in create_objective
    amici.petab.conditions.fill_in_parameters(
  File "/home/mkoenig/.virtualenvs/petabunit/lib/python3.12/site-packages/amici/petab/conditions.py", line 76, in fill_in_parameters
    fill_in_parameters_for_condition(
  File "/home/mkoenig/.virtualenvs/petabunit/lib/python3.12/site-packages/amici/petab/conditions.py", line 175, in fill_in_parameters_for_condition
    map_sim_var[par_id] for par_id in amici_model.getParameterIds()
    ~~~~~~~~~~~^^^^^^^^
KeyError: 'amici_k'
@dweindl
Copy link
Member

dweindl commented Jun 18, 2024

Sounds plausible. It's related to reserved names in amici (mostly some one-letter-IDs). It think this is not handled at all in pypesto. For a quick work-around, you can rename k to kk, k_, ...

@dweindl
Copy link
Member

dweindl commented Jun 18, 2024

Best to be handled directly in AMICI. Will leave this open here for others until there is an amici release where this is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AMICI bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants