question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

name 'ParameterMapping' is not defined

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
FFroehlichcommented, May 7, 2020

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

1reaction
FFroehlichcommented, May 7, 2020

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)

Read more comments on GitHub >

github_iconTop Results From Across the Web

getting syntax error name 'parameters' is not defined?
First thing is to be very careful with indentation; the code you have listed looks fine until the def execute . I hope...
Read more >
python - Calling function from for loop - issue with parameters ...
The first way you did it works because you are passing the NAME of ... it with a row which gets defined in...
Read more >
Variable not declared: <name> - HCL Product Documentation
This chapter describes the compile-time error messages in the LotusScript® language. Variable not declared: <name>.
Read more >
User's Manual: Functions and Variables - Apache JMeter
JMeter thread variables will have not been fully set up when the functions are processed, so variable names passed as parameters will not...
Read more >
How to fix the name error 'not defined' when trying to pass a ...
How do I fix the name error "not defined" when trying to pass a variable between functions in Python?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found