braintools.input.Composite

braintools.input.Composite#

class braintools.input.Composite(input1, input2, operator)#

Composite input created by combining two inputs with an operator.

Parameters:
  • input1 (Input) – First input operand.

  • input2 (Input) – Second input operand.

  • operator (str) – The operator to apply: ‘+’, ‘-’, ‘*’, ‘/’, ‘max’, ‘min’.

Notes

When inputs have different durations, the shorter one is padded with zeros to match the longer duration.

Division by zero returns the numerator value (avoiding NaN).

Examples

>>> # Direct construction (usually use operators instead)
>>> ramp = Ramp(0, 1, 100 * u.ms)
>>> sine = Sinusoidal(0.5, 10 * u.Hz, 100 * u.ms)
>>> added = Composite(ramp, sine, '+')
>>>
>>> # More commonly created via operators
>>> added = ramp + sine
>>> multiplied = ramp * sine
>>> maximum = ramp | sine  # Uses 'max' operator
__init__(input1, input2, operator)[source]#

Initialize a composite input.

Parameters:
  • input1 (Input) – First input.

  • input2 (Input) – Second input.

  • operator (str) – The operator to apply (‘+’, ‘-’, ‘*’, ‘/’, ‘max’, ‘min’).

Methods

__init__(input1, input2, operator)

Initialize a composite 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 composite 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.