Buffer#
- class prose.core.image.Buffer[source]#
Object to load and access adjacent items in a list
- Parameters:
size (int) – number of items accessible
loader (callable, optional) – a function that load an item in the buffer, by default None corresponding to lambda x: x
Example
from prose.core.image import Buffer import numpy as np # items to be loaded in the buffer init = np.arange(0, 10) # create and initialize buffer = Buffer(size=3) buffer.init(init) for buffer in buffer: print(buffer.previous, buffer.current, buffer.next)
None 0 1 0 1 2 1 2 3 2 3 4 3 4 5 4 5 6 5 6 7 6 7 8 7 8 9 8 9 None
Methods
__init__
(size[, loader])Object to load and access adjacent items in a list
append
(item)Add an item to the buffer (and delete last)
init
(items)Prepare items to be loaded in the buffer.
sub
(size, offset)Attributes
current
next
previous