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

Change numpy datatype to adapt to NumPy 2.0 #3226

Merged
merged 4 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 1 addition & 2 deletions pynest/nest/lib/hl_api_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ def Connect(pre, post, conn_spec=None, syn_spec=None, return_synapsecollection=F
}

if len(reduced_processed_syn_spec) > 0:
syn_param_keys = numpy.array(list(reduced_processed_syn_spec.keys()), dtype=numpy.string_)
syn_param_values = numpy.zeros([len(reduced_processed_syn_spec), len(pre)])

for i, value in enumerate(reduced_processed_syn_spec.values()):
Expand All @@ -260,7 +259,7 @@ def Connect(pre, post, conn_spec=None, syn_spec=None, return_synapsecollection=F
syn_param_keys = None
syn_param_values = None

connect_arrays(pre, post, weights, delays, synapse_model, syn_param_keys, syn_param_values)
connect_arrays(pre, post, weights, delays, synapse_model, reduced_processed_syn_spec.keys(), syn_param_values)

return

Expand Down
15 changes: 5 additions & 10 deletions pynest/pynestkernel.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -296,19 +296,14 @@ cdef class NESTEngine:
raise TypeError('weights must be a 1-dimensional NumPy array')
if delays is not None and not (isinstance(delays, numpy.ndarray) and delays.ndim == 1):
raise TypeError('delays must be a 1-dimensional NumPy array')
if syn_param_keys is not None and not ((isinstance(syn_param_keys, numpy.ndarray) and syn_param_keys.ndim == 1) and
numpy.issubdtype(syn_param_keys.dtype, numpy.string_)):
raise TypeError('syn_param_keys must be a 1-dimensional NumPy array of strings')
if syn_param_values is not None and not ((isinstance(syn_param_values, numpy.ndarray) and syn_param_values.ndim == 2)):
raise TypeError('syn_param_values must be a 2-dimensional NumPy array')

if not len(sources) == len(targets):
if len(sources) != len(targets):
raise ValueError('Sources and targets must be arrays of the same length.')
if weights is not None:
if not len(sources) == len(weights):
if weights is not None and len(sources) != len(weights):
raise ValueError('weights must be an array of the same length as sources and targets.')
if delays is not None:
if not len(sources) == len(delays):
if delays is not None and len(sources) != len(delays):
raise ValueError('delays must be an array of the same length as sources and targets.')
if syn_param_values is not None:
if not len(syn_param_keys) == syn_param_values.shape[0]:
Expand Down Expand Up @@ -338,8 +333,8 @@ cdef class NESTEngine:
# Storing parameter keys in a vector of strings
cdef vector[string] param_keys_ptr
if syn_param_keys is not None:
for i, key in enumerate(syn_param_keys):
param_keys_ptr.push_back(key)
for key in syn_param_keys:
param_keys_ptr.push_back(key.encode('utf8'))

cdef double[:, ::1] param_values_mv
cdef double* param_values_ptr = NULL
Expand Down
Loading