Skip to content
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

Easier way to get a string indexed dict of all probes #1367

Open
jgosmann opened this issue Oct 9, 2017 · 0 comments
Open

Easier way to get a string indexed dict of all probes #1367

jgosmann opened this issue Oct 9, 2017 · 0 comments

Comments

@jgosmann
Copy link
Collaborator

jgosmann commented Oct 9, 2017

I often want to probe some data from a Nengo model and save it to a file, either by calling np.savez myself or by returning a dict that later will be saved by the calling function. Unfortunately, I cannot directly use sim.data as dict to save because it is indexed by object instances (the probes). Thus, one has to define the probe and then manually list the conversion which often is in two different places (model definition vs. model execution and analysis):

with nengo.Network() as model:
    # model ...
    p_something = nengo.Probe(some.sub.net.something, synapse=0.01)

# run simulation and do stuff

np.savez('foo.npz', something=sim.data[p_something])

Note, that I have to type out the name something three times (I don't count some.sub.net.something because I might want to use a different name for probing/saving) and if I probe multiple things, there is some repeated code (nengo.Probe, sim.data[...]).

It would be nice to have some way to do this with only one line per probed thing to map the probed thing to a name to save it under and maybe a final statement to give all those things as a string indexed dict.

I'm not entirely sure how this should look like and whether it is something to be included in core Nengo or maybe more appropriate for nengo_extras.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant