Stream-level composition

Streams represent signals inside the model graph and are created automatically when you operate on an Input, Parameter, or Constant. Use stream methods to manipulate signal timing and routing before they are bound to outputs or composed into sub-models.

Common Stream operators:

  • Closed-loop and connect : create feedback or feedforward wiring from a signal to an Input using closedLoop() and connect(). These return a new Stream representing the connected signal.

  • Delays / z / time windows : postpone or window a stream with delay(), z(), tw() and sw().

  • Sampling windows : select past samples or time intervals with sw() (sample window) and tw() (time window). These are the primitives used by temporal building blocks (FIR, recurrent windows, etc.).

class nnodely.basic.relation.Stream(name, json, dim, count=1)[source]

Represents a stream of data inside the neural network. A Stream is automatically create when you operate over a Input, Parameter, or Constant object.

closedLoop(obj) Stream[source]

Update the Stream adding a closed loop connection with a given input object.

Parameters:

obj (Input) – The Input object to create a closed loop with.

Returns:

A Stream of the signal that updates the Inputs with the connection.

Return type:

Stream

Raises:
  • TypeError – If the provided object is not of type Input.

  • KeyError – If the input variable is already connected.

connect(obj) Stream[source]

Update the Stream adding a connects with a given input object.

Parameters:

obj (Input) – The Input object to connect to.

Returns:

A Stream of the signal that updates the Inputs with the connection.

Return type:

Stream

Raises:
  • TypeError – If the provided object is not of type Input.

  • KeyError – If the input variable is already connected.

delay(delay: int | float, *, name: str | None = None) Stream[source]

The function is used to delay a Stream. The value of the delay can be only positive.

Parameters:

delay (int, float) – The delay value.

Returns:

A Stream representing the delayed Stream

Return type:

Stream

s(order: int, *, int_name: str | None = None, der_name: str | None = None, method: str = 'euler') Stream[source]

Considering the Laplace transform notation. The function is used to operate an integral or derivate operation on a Stream. The order of the integral or the derivative operation is indicated by the order parameter.

Parameters:
  • order (int) – Order of the Laplace transform

  • method (str, optional) – Integration or derivation method

Returns:

A Stream of the signal represents the integral or derivation operation.

Return type:

Stream

sw(sw: int | list, offset: int | None = None, *, name: str | None = None) Stream[source]

Selects a sample window on Stream. It is possible to create a smaller or bigger window on the stream. The Sample Window must be in the past not in the future.

Parameters:
  • sw (int, list) – The sample window represents the number of steps in the past. If a list, it should contain the start and end indices, both indexes must be in the past.

  • offset (int, optional) – The offset for the sample window. Default is None.

  • name (str, None) – The name of the internal variable

Returns:

A Stream representing the SamplePart object with the selected samples.

Return type:

Stream

tw(tw: float | int | list, offset: float | int | None = None, *, name: str | None = None) Stream[source]

Selects a time window on Stream. It is possible to create a smaller or bigger time window on the stream. The Time Window must be in the past not in the future.

Parameters:
  • tw (float, int, list) – The time window represents the time in the past. If a list, it should contain the start and end times, both indexes must be in the past.

  • offset (float, int, optional) – The offset for the sample window. Default is None.

  • name (str, None) – The name of the internal variable

Returns:

A Stream representing the TimePart object with the selected time window.

Return type:

Stream

z(delay: int | float, *, name: str | None = None) Stream[source]

Considering the Zeta transform notation. The function is used to delay a Stream. The value of the delay can be only positive.

Parameters:

delay (int) – The delay value.

Returns:

A Stream representing the delayed Stream

Return type:

Stream