braintools.input.Clipped

braintools.input.Clipped#

class braintools.input.Clipped(input_obj, min_val=None, max_val=None)#

Clipped version of an input.

Clips input values to stay within specified bounds, useful for modeling saturation or rectification.

Parameters:
  • input_obj (Input) – The input to clip.

  • min_val (float | None) – Minimum value. If None, no lower bound.

  • max_val (float | None) – Maximum value. If None, no upper bound.

Examples

>>> ramp = Ramp(-2, 2, 200 * u.ms)
>>>
>>> # Clip to [0, 1] range
>>> saturated = Clipped(ramp, 0, 1)
>>>
>>> # Only lower bound (rectification)
>>> rectified = Clipped(ramp, min_val=0)
>>>
>>> # Only upper bound (saturation)
>>> capped = Clipped(ramp, max_val=1.5)
>>>
>>> # Usually created via clip() method
>>> saturated = ramp.clip(0, 1)
__init__(input_obj, min_val=None, max_val=None)[source]#

Initialize clipped input.

Parameters:
  • input_obj (Input) – The input to clip.

  • min_val (float | None) – Minimum value.

  • max_val (float | None) – Maximum value.

Methods

__init__(input_obj[, min_val, max_val])

Initialize clipped input.

apply(func)

Apply a custom function to the input.

clip([min_val, max_val])

Clip the input values to a range.

generate()

Generate the clipped input.

repeat(n_times)

Repeat the input pattern n times.

scale(factor)

Scale the input by a factor.

shift(time_shift)

Shift the input in time.

smooth(tau)

Apply exponential smoothing to the input.

Attributes

dt

Get the time step from global environment.

n_steps

Get the number of time steps.

shape

Get the shape of the input array.