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

Disallow specifying lists of synapse models #2317

Merged
merged 6 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions pynest/nest/lib/hl_api_connection_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,18 @@ def _process_syn_spec(syn_spec, conn_spec, prelength, postlength, use_connect_ar
# for use_connect_arrays, return "static_synapse" by default
if use_connect_arrays:
return {"synapse_model": "static_synapse"}

return syn_spec

rule = conn_spec['rule']
if isinstance(syn_spec, CollocatedSynapses):
return syn_spec

if isinstance(syn_spec, str):
return {"synapse_model": syn_spec}
elif isinstance(syn_spec, dict):

rule = conn_spec['rule']
if isinstance(syn_spec, dict):
if "synapse_model" in syn_spec and not isinstance(syn_spec["synapse_model"], str):
raise kernel.NESTError("'synapse_model' must be a string")
for key, value in syn_spec.items():
# if value is a list, it is converted to a numpy array
if isinstance(value, (list, tuple)):
Expand Down Expand Up @@ -138,10 +142,9 @@ def _process_syn_spec(syn_spec, conn_spec, prelength, postlength, use_connect_ar
syn_spec["synapse_model"] = "static_synapse"

return syn_spec
elif isinstance(syn_spec, CollocatedSynapses):
return syn_spec

raise TypeError("syn_spec must be a string or dict")
# If we get here, syn_spec is of illegal type.
raise TypeError("syn_spec must be a string, dict or CollocatedSynapses object")


def _process_spatial_projections(conn_spec, syn_spec):
Expand Down
2 changes: 1 addition & 1 deletion pynest/pynestkernel.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ cdef inline Datum* python_object_to_datum(obj) except NULL:
elif numpy.issubdtype(obj.dtype, numpy.floating):
ret = python_buffer_to_datum[object, double](obj)
else:
clinssen marked this conversation as resolved.
Show resolved Hide resolved
raise NESTError.PyNESTError("only vectors of integers or floats are supported")
raise NESTErrors.PyNESTError("only vectors of integers or floats are supported")
clinssen marked this conversation as resolved.
Show resolved Hide resolved

if ret is NULL:
try:
Expand Down