Closed anandtrex closed 4 years ago
No not directly (yet), but you may use the flatten_dictionary
function in pypet.utils.helpful_functions
:
from pypet.utils.helpful_functions import flatten_dictionary
flatten_dict = flatten_dictionary(nested_dict, '.')
for name, val in flatten_dict.items():
traj.f_add_parameter(name, val)
Cool. That seems to work. Thanks.
I added some further functionality to that function to be able to handle lists of dictionaries within the dictionary. For example, if one of the values happened to be dict(a=[dict(b=1), dict(b=2)]
this would be flattened to 'a.0.b' (=1) and 'a.1.b' (=2).
If this seems to be some functionality you think might be worth having in the main pypet codebase, I could send a pull request.
Sorry for my delayed answer. How, do you know or distinguish if a list in your nested dictionary is not user data, i.e. should translate into data in a leaf node, but a list of potential nodes?
inactive
Is it possible to add parameters using a single dictionary?
For example, in the tutorial, instead of doing this:
It would be nice if one could do this:
Or with comments, each value being a tuple like
V_init=(0.0, 'The initial condition for the membrane potential')
and so on.I currently have a large number of model parameters which are already parsed into a dictionary. I was unable to find definitive information on whether pypet already supports this. I think it would be a really useful feature.