MCPcopy
hub / github.com/dask/dask / cached_cumsum

Function cached_cumsum

dask/utils.py:2125–2151  ·  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

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…