Skip to content

Commit

Permalink
Changed the moment where index arrays are cast to numpy arrays as req…
Browse files Browse the repository at this point in the history
…uested

by @neworderofjamie
  • Loading branch information
tnowotny committed Sep 5, 2023
1 parent 64c5f31 commit 60c0511
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pygenn/genn_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,10 @@ def set_sparse_connections(self, pre_indices, post_indices):
raise Exception("when weight sharing is used, set_sparse_connections"
"can only be used on the 'master' population")
elif self.is_ragged:
# Cast index arrays to numpy arrays if necessary
pre_indices = np.asarray(pre_indices)
post_indices = np.asarray(post_indices)

# Lexically sort indices
self.synapse_order = np.lexsort((post_indices, pre_indices))

Expand All @@ -1010,7 +1014,7 @@ def set_sparse_connections(self, pre_indices, post_indices):
self.pop.set_max_connections(max_row_length)

# Set ind to sorted postsynaptic indices
self.ind = np.asarray(post_indices)[self.synapse_order]
self.ind = post_indices[self.synapse_order]

# Cache the row lengths
self.row_lengths = row_lengths
Expand Down

0 comments on commit 60c0511

Please sign in to comment.