SynapseCollection#

class brainpy.state.network.SynapseCollection(spanned)#

A filtered, lazy view over realized synapses (NEST SynapseCollection).

Returned by get_connections(). It stores, per spanned projection, only the kept edge indices and their population-local source / targetno copy of weight or delay. Each get() re-reads weight / delay from the live projection, so a query made before simulate() still reflects post-simulation evolved plastic weights.

Methods mirror the NEST object: get() (one key -> array, a list of keys -> dict), set() ('weight' / 'delay' write-back, guarded), the source / target arrays, len(), iteration over (source, target) pairs, and repr.

Notes

source / target are population-local indices (brainpy.state has no global node-id space). set('weight', value) accepts a scalar (broadcast to every edge) or a full per-edge array; a per-edge array is refused on a homogeneous-weight projection, and any write is refused on a projection whose plastic rule evolves the weight. set('delay', scalar) is homogeneous per projection (grid-rounded to dt) and applies only to the static event path.

get(key)[source]#

Read a connection attribute (or several).

Parameters:

key (str or list of str) – One of 'source', 'target', 'weight', 'delay' — or a list of them.

Returns:

A single array/Quantity for a string key (weight / delay carry their unit and are read live), or a {key: value} dict for a list.

Return type:

numpy.ndarray or brainunit.Quantity or dict

set(key, value)[source]#

Write a connection attribute back into the live projections.

Parameters:
  • key (str) – 'weight' or 'delay' ('source' / 'target' are read-only).

  • value (scalar, array, or brainunit.Quantity) – For 'weight': a scalar broadcasts to every edge, a per-edge array sets each edge. For 'delay': a scalar homogeneous delay per projection.

Raises:
  • ValueError – A per-edge weight on a homogeneous-weight projection; any weight write on a weight-evolving plastic projection; or a delay write on a plastic projection.

  • KeyError – A key other than 'weight' / 'delay'.

property source#

Population-local source index per edge ((N,) int array).

property target#

Population-local target index per edge ((N,) int array).