Utilities

Utility classes and functions for eyelink-wrapper.

This module contains shared utilities used across the package, including the RingBuffer class for efficient sample storage.

class pyelink.utils.RingBuffer(maxlen=200)[source]

Bases: object

A simple ring buffer based on the deque class.

Parameters:

maxlen (int)

__init__(maxlen=200)[source]

Initialize ring buffer with specified maximum length.

Parameters:

maxlen (int) – Maximum number of elements the buffer can hold

Return type:

None

clear()[source]

Clear all elements from the buffer.

Return type:

None

get_all()[source]

Return all samples from buffer and empty the buffer.

Returns:

All samples that were in the buffer

Return type:

list

peek()[source]

Return all samples from buffer without emptying the buffer.

Creates a temporary copy of the buffer to read values non-destructively.

Returns:

All samples currently in the buffer

Return type:

list

peek_time_range(t0, t1)[source]

Return samples from buffer within time range without emptying buffer.

Assumes samples are stored with timestamp as first element: [timestamp, …]

Parameters:
  • t0 (float) – Start time of range (inclusive)

  • t1 (float) – End time of range (inclusive)

Returns:

Samples with timestamps between t0 and t1

Return type:

list

append(l)[source]

Append buffer with the most recent sample.

Parameters:

l (list) – Sample data to append (typically a list with timestamp and values)

Return type:

None