ess.reduce.streaming.Accumulator#

class ess.reduce.streaming.Accumulator(preprocess=<function maybe_hist>)[source]#

Abstract base class for accumulators.

Accumulators are used to accumulate values over multiple chunks.

__init__(preprocess=<function maybe_hist>)[source]#
Parameters:

preprocess (Callable[[TypeVar(T)], TypeVar(T)] | None, default: <function maybe_hist at 0x7f7d70fd52d0>) – Preprocessing function to be applied to pushed values prior to accumulation.

Methods

__init__([preprocess])

clear()

Clear the accumulator, resetting it to its initial state.

push(value)

Push a value to the accumulator.

Attributes

is_empty

Check if the accumulator is empty.

value

Get the accumulated value.

abstract clear()[source]#

Clear the accumulator, resetting it to its initial state.

Return type:

None

property is_empty: bool#

Check if the accumulator is empty.

Returns:

True if the accumulator is empty, False otherwise.

push(value)[source]#

Push a value to the accumulator.

Parameters:

value (TypeVar(T)) – Value to be pushed to the accumulator.

Return type:

None

property value: T#

Get the accumulated value.

Returns:

Accumulated value.

Raises:

ValueError – If the accumulator is empty.