pyPESTO: name 'ParameterMapping' is not defined

I am just trying to reproduce the AMICI Python example “Boehm” from the documentation. However, in cell 14:

model.requireSensitivitiesForAllParameters()
solver.setSensitivityMethod(amici.SensitivityMethod_forward)
solver.setSensitivityOrder(amici.SensitivityOrder_first)
objective = pypesto.AmiciObjective(model, solver, [edata], 1)

I get the following error:

NameError                                 Traceback (most recent call last)
<ipython-input-26-8453b4d05827> in <module>()
      6 
      7 
----> 8 objective = pypesto.AmiciObjective(model, solver, [edata], 1)

/media/sf_DPhil_Project/Project07_Parameter Fitting/pyPESTO/pypesto/objective/amici_objective.py in __init__(self, amici_model, amici_solver, edatas, max_sensi_order, x_ids, x_names, parameter_mapping, guess_steadystate, n_threads, amici_object_builder, calculator)
    163             # use identity mapping for each condition
    164             parameter_mapping = create_identity_parameter_mapping(
--> 165                 amici_model, len(edatas))
    166         self.parameter_mapping = parameter_mapping
    167 

/media/sf_DPhil_Project/Project07_Parameter Fitting/pyPESTO/pypesto/objective/amici_util.py in create_identity_parameter_mapping(amici_model, n_conditions)
     98     x_ids = list(amici_model.getParameterIds())
     99     x_scales = list(amici_model.getParameterScale())
--> 100     parameter_mapping = ParameterMapping()
    101     for _ in range(n_conditions):
    102         condition_map_sim_var = {x_id: x_id for x_id in x_ids}

NameError: name 'ParameterMapping' is not defined

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (10 by maintainers)

Most upvoted comments

IPython may not have been installed in the virtual environment. Thus, when you invoke jupyter, implicitly the next available one is called, which may however be from a different python environment. You can check the context of your ipython environment by e.g. executing !which python3 in a notebook cell.

To fix this, proceed as in the above link, usually pip install ipython jupyter (where pip is from the virtual environment) should do the trick.

You can also start jupyter/ipython from outside the virtual env and just select a different kernel for execution: https://doc.cocalc.com/howto/jupyter-kernel-selection.html

I just pip installed it today and it should be the right version:

In [27]: amici.__version__
Out[27]: '0.10.21'

Make sure the notebook is using the kernel from the right virtual environment where the latest version of amici is installed (see https://ipython.readthedocs.io/en/stable/install/kernel_install.html)