API¶
-
slice_aggregator.
slices_by_ixs
(*, zero_factory: typing.Callable[[], V] = None, zero_test: typing.Callable[[V], bool] = None) → slice_aggregator.by_ixs.Aggregator[V]¶ Returns an object that allows assigning values to slices and aggregating them by indices
Parameters: - zero_factory – callable returning additive identity
- zero_test – test for equality to zero
Returns: a new instance of
slice_aggregator.by_ixs.Aggregator
-
slice_aggregator.
ixs_by_slices
(*, zero_factory: typing.Callable[[], V] = None, zero_test: typing.Callable[[V], bool] = None) → slice_aggregator.by_slices.Aggregator[V]¶ Returns an object that allows assigning values to indices and aggregating them by slices
Parameters: - zero_factory – callable returning additive identity
- zero_test – test for equality to zero
Returns: a new instance of
slice_aggregator.by_slices.Aggregator
-
class
slice_aggregator.by_ixs.
Aggregator
(*, dual: slice_aggregator.by_slices.Aggregator, zero_factory: typing.Callable[[], V] = None)¶ A data structure for assigning values to slices and aggregating them by indices
It provides a method-based interface and an alternative based on __getitem__ and slices.
Warning: Only the method-based interface is suitable for custom values handling inplace operators. Read the documentation on advances usage for more details.
-
get
(ix: int) → V¶ Get the aggregated value of all slices containing the specified index
-
inc
(start: typing.Union[int, NoneType], stop: typing.Union[int, NoneType], value: V) → None¶ Increment the value assigned to a slice
-
dec
(start: typing.Union[int, NoneType], stop: typing.Union[int, NoneType], value: V) → None¶ Decrement the value assigned to a slice
-
-
class
slice_aggregator.by_slices.
Aggregator
¶ A data structure for assigning values to indices and aggregating them by slices
It provides a method-based interface and an alternative based on __getitem__ and slices.
Warning Only the method-based interface is suitable for custom values handling inplace operators. Read the documentation on advances usage for more details.
-
get
(start: typing.Union[int, NoneType], stop: typing.Union[int, NoneType]) → V¶ Get the aggregated value of all indices contained by the specified slice
-
inc
(ix: int, value: V) → None¶ Increment the value assigned to an index
-
dec
(ix: int, value: V) → None¶ Decrement the value assigned to an index
-
set
(ix: int, value: V) → None¶ Set the value assigned to an index
-