-
Notifications
You must be signed in to change notification settings - Fork 0
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
Using get to obtain a dictionary with parameters from GIDCollections #1
Comments
I am wondering if nodes = nest.Create('iaf_psc_alpha', 10)
V_m = nodes.get('V_m')['V_m']
C_a = nodes.get('C_a')['C_a'] To me, I expect As a reference, I think it makes perfect sense when you send in a list to g = nodes.get(['local', 'thread', 'vp'])
local = g['local']
thread = g['thread']
vp = g['vp'] makes sense to me. I understand that if I think it is nice that the return value of |
@stinebuu: I fully agree with your observation and upon thinking about it again I am not even sure that the dictionary is a good idea. Usually user's should know what they asked for and in which order and the dictionary just adds overhead and indirections when accessing the data. I also think we can in general leave out the GID. If user's want it GID, they can simply include the key We should in any case not try to always return the same type if this goes against user expectation, which it probably does in some cases. What about the following semantics (using the examples by @hakonsbm)? >>> nrns.get('V_m')
[-70.0, -71.0, ...]
# Rationale: the user asked for the membrane potentials of a set of neurons and thus
# will get them all in a list (or maybe better as a NumPy array).
>>> nrns[::10].get('V_m')
[-70.0, -80.0, ...]
# Same as above
>>> nrns[3].get('V_m')
-73.0
# Rationale: If the GIDCollection only contains a single element, users probably
# know this and thus would probably want to get the value directly instead of a
# single-element list.
>>> nrns.get(['V_m', 'I_e'])
[[-70.0, -71.0, ...], [5.0, 6.0, ...]]
# Rationale: The user provides a list of keys and gets back a list of results. If the
# GC only contains a single element, the returned list could again contain the results
# just as values instead of lists. Maybe using tuples as outer containers is better.
>> sd.get('events', 'senders')
[5, 24, 12, ...]
# Rationale: This is basically the same as getting V_m. Users ask for all event
# senders and will get them as a list. If the second argument is a list, the result
# would again be a list of lists. I did not yet think through how this would carry over
# to the case where sd contains multiple elements. Probably it just does ;-)
>> layer.get(['center', 'positions'])
[(0.0, 0.0), ((0.6, 0.1), (0.4, 0.3), ...)]
# Rationale: Users again know what they asked for and in which order Regarding this question from above:
I think only the last argument to @heplesser, what do you think? |
@jougs I think this looks sensible. I also think that we should be able to call >>> nrns.get()
({'C_m': 250.0,
'Ca': 0.0,
...
},
...,
{'C_m': 250.0,
'Ca': 0.0,
...,
'vp': 0}) we could have >>> nrns.get()
{'C_m': [250.0, 250.0, ..., 250.0],
'Ca': [0.0, 0.0, ..., 0.0],
...
'vp': [0, 0, ... , 0]
} |
@stinebuu @jougs Thank you for all the good suggestions! But I still have several issues. Single-node accessWhen a user explicitly writes nrns[3].get('V_m') it is indeed clear that a value of a single neuron is requested. But if I have a script like e = nest.Create('iaf_psc_alpha', 2)
i = nest.Create('iaf_psc_alpha', 1)
# ... lots of other code ...
for p in [e, i]:
res = p.get('V_m')
# ... work with res ... I will have a problem, in particular, because at the point where I use� I can think of three alternatives:
Dictionary vs list of arrays as return typeI strongly favour dictionaries instead of lists of lists or arrays, except when requesting a single field. I.e., >>> nrns.get(['V_m', 'V_th'])
{'V_m': [-70., ...], 'V_th': [-55., ...]}
>>> nrns.get('V_m')
[-70., ...]
>>> nrns[0].get('V_m') # with alt 2 from above
-70
>>> nrns[0].get(['V_m', 'V_th']) # with alt 2 from above
{'V_m': -70, 'V_th': -55}
Hierarchical field addressingI am not quite sure about how to solve this one in a consistent way. The main issue is how to select multiple fields at a deeper hierarchy level. The most relevant use case in that respect is
We could set up the following rules:
Examples: >>> nrns.get('V_m', 'V_th')
{'V_m': [-70, ...], 'V_th': [-55, ...]}
>>> sds.get('global_id', 'n_events')
{'global_id': [2, 3], 'n_events': [10, 11]}
>>> sds.get('global_id', 'events')
{'global_id': [2, 3], 'events': [{...}, {...}]}
>>> sds.get('global_id', ['events', 'senders', 'times', 'V_m', 'V_th'])
{'global_id': [2, 3], 'times': [[...], [...]], 'senders': [[...], [...]],
'V_m': [[...], [...]], 'V_th': [[...], [...]], } |
Summary after VC 1 DecemberReturn values
>>> nrns.get(['V_m', 'V_th'])
{'V_m': [-70., ...], 'V_th': [-55., ...]}
>>> nrns.get('V_m')
[-70., ...] Hierarchical addressing
>>> mm[0].get('events', ['times', 'V_m'])
{'times': [0.1, 0.2, ...], 'V_m': [-70.0, -69.5, ...]} Open issuesInhomogenous collections
The last option seems to be the most promising one. Composite valuesSome models, in particular recorders, provide data in form of arrays, e.g.,
>>> mms.get('events', ['times', 'V_m'])
{'times': [[0.1, 0.2, ...], [0.1, 0.2, ...]] ,
'V_m': [[-70.0, -69.5, ...], [-65.0, -71.0, ...]]}
Option 1 is most likely sufficiently safe and would in almost all cases lead to errors that are easily noticed if users should mistake dimension. |
Fix merge and formatting issues for erfc neuron
Fix bytestring problems occuring with Python3
Revisions to the gamma parameter code
refactoring of comment blocks in models/o-z and precise
Just as a reminder for me and @hakonsbm: Everything with |
With the GIDCollection object one should be able to get parameters of all the nodes, or if it's a layer, get parameters of the layer. We will do this with the function
get
. This will replace the currentGetStatus
function, which will be marked as deprecated.Input
Input to
get
can be one of the following:Output
The result should be a dictionary containing an entry for the GIDs and an entry for the corresponding parameter values, or more entries if one inputs multiple parameters. The entries contain arrays of the same length, so that each parameter value is mapped to the GID of the same index in the GID-array.
Examples
Python
SLI
Current challenges
The text was updated successfully, but these errors were encountered: