|
19 | 19 | # You should have received a copy of the GNU General Public License |
20 | 20 | # along with NEST. If not, see <http://www.gnu.org/licenses/>. |
21 | 21 |
|
| 22 | +from typing import Mapping, Tuple |
| 23 | + |
22 | 24 | import importlib |
23 | 25 | import multiprocessing |
24 | 26 | import os |
@@ -65,23 +67,28 @@ def _get_model_parameters_and_state(cls, nestml_file_name: str): |
65 | 67 | parameters_list = [p for p in dir(neuron.Parameters_) if not "__" in p] |
66 | 68 | parameters = {p: getattr(neuron, "get_" + p)() for p in parameters_list} |
67 | 69 |
|
| 70 | + internals_list = [p for p in dir(neuron.Variables_) if not "__" in p] |
| 71 | + internals = {p: getattr(neuron, "get_" + p)() for p in internals_list} |
| 72 | + |
68 | 73 | if "ode_state_variable_name_to_index" in dir(neuron.State_): |
69 | 74 | state_list = neuron.State_.ode_state_variable_name_to_index.keys() |
70 | 75 | else: |
71 | 76 | state_list = [p for p in dir(neuron.State_) if not "__" in p] |
72 | 77 | state_vars = {p: getattr(neuron, "get_" + p)() for p in state_list} |
73 | 78 |
|
74 | | - return parameters, state_vars |
| 79 | + return parameters, internals, state_vars |
75 | 80 |
|
76 | 81 | @classmethod |
77 | | - def get_neuron_parameters_and_state(cls, nestml_file_name: str) -> tuple[dict, dict]: |
| 82 | + def get_neuron_numerical_initial_values(cls, nestml_file_name: str) -> Tuple[Mapping[str, float], Mapping[str, float], Mapping[str, float]]: |
78 | 83 | r""" |
79 | | - Get the parameters for the given neuron model. The code is generated for the model for Python standalone target |
80 | | - The parameters and state variables are then queried by creating the neuron in Python standalone simulator. |
| 84 | + Get the numerical values of the parameters, internals, and state variables for the given neuron model. |
| 85 | +
|
| 86 | + Internally, code is generated for the model for the Python standalone target, and then the value is read off by instantiating the resulting code. |
| 87 | +
|
81 | 88 | :param nestml_file_name: File name of the neuron model |
82 | | - :return: A dictionary of parameters and state variables |
| 89 | + :return: Dictionaries mapping parameters, internals and state variables to their numerical initial values |
83 | 90 | """ |
84 | | - parameters, state = cls._get_model_parameters_and_state(nestml_file_name) |
| 91 | + parameters, internals, state = cls._get_model_parameters_and_state(nestml_file_name) |
85 | 92 |
|
86 | 93 | if not parameters or not state: |
87 | 94 | Logger.log_message(None, -1, |
|
0 commit comments