MCPcopy Create free account
hub / github.com/dask/dask / cached_cumsum

Function cached_cumsum

dask/utils.py:2128–2154  ·  view source on GitHub ↗

Compute :meth:`toolz.accumulate` with caching. Caching is by the identify of `seq` rather than the value. It is thus important that `seq` is a tuple of immutable objects, and this function is intended for use where `seq` is a value that will persist (generally block sizes). Par

(seq, initial_zero=False)

Source from the content-addressed store, hash-verified

2126
2127
2128def cached_cumsum(seq, initial_zero=False):
2129 """Compute :meth:`toolz.accumulate` with caching.
2130
2131 Caching is by the identify of `seq` rather than the value. It is thus
2132 important that `seq` is a tuple of immutable objects, and this function
2133 is intended for use where `seq` is a value that will persist (generally
2134 block sizes).
2135
2136 Parameters
2137 ----------
2138 seq : tuple
2139 Values to cumulatively sum.
2140 initial_zero : bool, optional
2141 If true, the return value is prefixed with a zero.
2142
2143 Returns
2144 -------
2145 tuple
2146 """
2147 if isinstance(seq, tuple):
2148 # Look up by identity first, to avoid a linear-time __hash__
2149 # if we've seen this tuple object before.
2150 result = _cumsum(_HashIdWrapper(seq), initial_zero)
2151 else:
2152 # Construct a temporary tuple, and look up by value.
2153 result = _cumsum(tuple(seq), initial_zero)
2154 return result
2155
2156
2157def show_versions() -> None:

Callers 15

__init__Method · 0.90
test_cached_cumsumFunction · 0.90
test_cached_cumsum_nanFunction · 0.90
_slice_1dFunction · 0.90
setitem_arrayFunction · 0.90
slices_from_chunksFunction · 0.90
map_blocksFunction · 0.90
shapeMethod · 0.90
_vindex_arrayFunction · 0.90
grid_pointsFunction · 0.90

Calls 2

_cumsumFunction · 0.85
_HashIdWrapperClass · 0.85

Tested by 3

test_cached_cumsumFunction · 0.72
test_cached_cumsum_nanFunction · 0.72