rate_connection_delayed#
- class brainpy.state.rate_connection_delayed(*args, **kwargs)#
NEST-compatible
rate_connection_delayedconnection spec.Carries the NEST-facing parameters and status of a delayed rate connection: a scalar
weightand an integerdelay_steps(>= 1). It mirrors NEST’sGetStatus/SetStatussurface (weight,delay/delay_stepsaliases,has_delay,supports_wfr) so connection parameters round-trip identically to the C++ model.The delayed rate coupling itself is realized by the Simulator’s continuous-rate (seam-(H)) emission path: a presynaptic rate neuron emits its graded
rateeach step, and the connection routesweight · ratethrough an input delay line ofdelay_stepssteps (delay_steps · dtof latency) into the postsynaptic neuron’s delta input channel, which the post reads viasum_delta_inputs. This spec object carries the parameters; the Simulator builds the delay line from them.Unlike
rate_connection_instantaneous, this model enforces a minimum delay of one simulation step.- Parameters:
weight (
floatorarray-like, optional) – Connection gain/strength applied to transmitted rate signals. Must be scalar. Default:1.0.delay_steps (
intorarray-like, optional) – Transmission delay in discrete simulation steps. Must be integer-valued and>= 1. Default:1.name (
strorNone, optional) – Optional name identifier for this connection instance. Default:None.
Parameter Mapping
The following table maps NEST parameters to this implementation:
NEST Parameter
brainpy.state
Notes
weightweightConnection gain (scalar float)
delaydelay_stepsDelay in steps (integer
>= 1)has_delayHAS_DELAYAlways
True(class attribute)supports_wfrSUPPORTS_WFRAlways
False(class attribute)Mathematical Description
A delayed connection transmits a rate signal \(r_\text{pre}\) to the postsynaptic neuron with delay \(d\) and weight \(w\):
\[r_\text{post}(t) = w \cdot r_\text{pre}(t - d)\]In discrete-time simulation with step size \(\Delta t\), the delay is quantized to an integer number of steps \(d_\text{steps} \geq 1\), and on the JAX substrate is realized by an input delay line of length \(d_\text{steps}\):
\[d_\text{steps} = \left\lceil \frac{d}{\Delta t} \right\rceil, \quad d_\text{steps} \geq 1\]The presynaptic rate captured at step \(k\) is therefore deposited into the postsynaptic input at step \(k + d_\text{steps}\), matching NEST’s delayed rate delivery.
Implementation Notes
Delay Validation
This model enforces
delay_steps >= 1to comply with NEST semantics. Attempting to setdelay_steps = 0raises aValueError. For instantaneous (zero-delay) connections, userate_connection_instantaneousinstead.Unit Handling
All parameters accept
brainunit.Quantityobjects or plain numeric values. If aQuantityis provided, its mantissa is extracted. Internally, values are stored as dimensionless floats or integers.Compatibility with NEST
NEST stores delays in time units (ms), while this implementation uses discrete steps to match BrainPy’s event system.
The
set_statusmethod accepts bothdelayanddelay_stepsas aliases (if both are provided, they must be identical).
- Raises:
ValueError – If
weightordelay_stepsis not scalar, or ifdelay_steps < 1.ValueError – If
delayanddelay_stepsare both provided inset_statuswith conflicting values.
See also
rate_connection_instantaneousZero-delay rate connection model (NEST equivalent)
rate_neuron_ipnInput rate neuron (delayed rate receiver)
rate_neuron_opnOutput rate neuron (delayed rate receiver)
References
Examples
Basic Usage
Create a delayed connection with weight 2.0 and 3-step delay:
>>> from brainpy import state as bst >>> conn = bst.rate_connection_delayed(weight=2.0, delay_steps=3) >>> conn.get_status() {'weight': 2.0, 'delay_steps': 3, 'delay': 3, 'has_delay': True, 'supports_wfr': False}
Dynamic Parameter Updates
Update connection parameters at runtime:
>>> conn.set_status(weight=1.5, delay_steps=5) >>> conn.get('weight') 1.5 >>> conn.get('delay_steps') 5
Delay Validation
Zero or sub-step delays are rejected:
>>> conn.set_delay_steps(0) Traceback (most recent call last): ... ValueError: delay_steps must be >= 1.
Using with Rate Neurons
Typical usage in a rate-based network — the Simulator builds the delay line from the connection’s
delay_steps:>>> import brainunit as u >>> from brainpy import state as bst >>> sim = bst.Simulator(dt=0.1 * u.ms) >>> pre = sim.create(bst.lin_rate_ipn, 10, params=dict(tau=10.0 * u.ms)) >>> post = sim.create(bst.lin_rate_ipn, 5, params=dict(tau=10.0 * u.ms)) >>> proj = sim.connect(pre, post, weight=0.5, delay=0.3 * u.ms, comm='dense')
- get(key='status')[source]#
Retrieve a specific parameter or full status dictionary.
- Parameters:
key (
str, optional) – Parameter name to retrieve. Special value'status'returns full status dictionary. Supported keys:'status','weight','delay','delay_steps','has_delay','supports_wfr'. Default:'status'.- Returns:
If
key == 'status', returns full status dictionary. Otherwise, returns the requested parameter value.- Return type:
dictorscalar- Raises:
KeyError – If
keyis not a recognized parameter name.
Examples
>>> conn = rate_connection_delayed(weight=2.0, delay_steps=3) >>> conn.get('weight') 2.0 >>> conn.get('delay_steps') 3 >>> conn.get('status') {'weight': 2.0, 'delay_steps': 3, ...}
- get_status()[source]#
Retrieve all connection parameters as a dictionary.
Follows NEST’s
GetStatusAPI convention.- Returns:
Dictionary with keys:
'weight'(float): Connection gain.'delay_steps'(int): Delay in simulation steps.'delay'(int): Alias fordelay_steps(NEST compatibility).'has_delay'(bool): AlwaysTrue.'supports_wfr'(bool): AlwaysFalse.
- Return type:
Examples
>>> conn = rate_connection_delayed(weight=1.5, delay_steps=2) >>> status = conn.get_status() >>> status['weight'] 1.5 >>> status['delay'] 2
- property properties#
Return connection model properties.
- Returns:
Dictionary with keys:
'has_delay'(bool): AlwaysTruefor this model.'supports_wfr'(bool): AlwaysFalse(waveform relaxation not supported).
- Return type:
- set_delay(delay)[source]#
Update the connection delay (alias for
set_delay_steps).- Parameters:
delay (
intorarray-like) – New delay in simulation steps. Must be integer-valued scalar>= 1. Acceptsbrainunit.Quantity(mantissa will be extracted).- Raises:
ValueError – If
delayis not scalar, not integer-valued, or< 1.
Examples
>>> conn = rate_connection_delayed() >>> conn.set_delay(5) >>> conn.get('delay_steps') 5
- set_delay_steps(delay_steps)[source]#
Update the connection delay in simulation steps.
- Parameters:
delay_steps (
intorarray-like) – New delay in simulation steps. Must be integer-valued scalar>= 1. Acceptsbrainunit.Quantity(mantissa will be extracted).- Raises:
ValueError – If
delay_stepsis not scalar, not integer-valued, or< 1.
Examples
>>> conn = rate_connection_delayed() >>> conn.set_delay_steps(3) >>> conn.get('delay_steps') 3
- set_status(status=None, **kwargs)[source]#
Update connection parameters from a dictionary or keyword arguments.
Follows NEST’s
SetStatusAPI convention. Accepts bothdelayanddelay_stepsas aliases (if both provided, they must match).- Parameters:
- Raises:
ValueError – If
delayanddelay_stepsare both provided with conflicting values.ValueError – If any parameter fails validation (e.g., non-scalar, delay < 1).
Examples
>>> conn = rate_connection_delayed(weight=1.0, delay_steps=1) >>> conn.set_status({'weight': 2.5, 'delay_steps': 4}) >>> conn.get('weight') 2.5 >>> conn.set_status(weight=3.0) # Keyword argument style >>> conn.get('weight') 3.0
- set_weight(weight)[source]#
Update the connection weight.
- Parameters:
weight (
floatorarray-like) – New connection gain. Must be scalar. Acceptsbrainunit.Quantity(mantissa will be extracted).- Raises:
ValueError – If
weightis not scalar.
Examples
>>> conn = rate_connection_delayed() >>> conn.set_weight(2.5) >>> conn.get('weight') 2.5