CircularBuffer

class torch_sim.properties.correlations.CircularBuffer(size, device=None)[source]

Bases: object

Circular buffer for storing time series data.

Provides a fixed-size circular buffer optimized for storing and retrieving time series data, with minimal memory allocation.

Variables:
  • size – Maximum number of elements to store

  • buffer – Storage for the data

  • head – Current write position

  • count – Number of elements currently stored

  • device – Device where the buffer is stored

Parameters:
append(value)[source]

Append a new value to the buffer.

Parameters:

value (Tensor) – New tensor to store

Return type:

None

get_array()[source]

Get the current buffer contents as a tensor.

Returns:

Tensor containing the buffered data in chron. order

Return type:

Tensor

property is_full: bool

Check if the buffer is full.