/ concept-collection / benchcompress
Sign in
concept-collection / benchcompress
fix ans delta
Jeremy Magland <jmagland@flatironinstitute.org> committed commit a54f9fc0edb1 parent 36cf327 Browse files
1 changed file+2−6
zia_benchmark/src/zia_benchmark/algorithms/simple_ans/__init__.pymodified+2−6View file
@@ -73,12 +73,8 @@ def simple_ans_delta_decode(x: bytes, dtype: str) -> np.ndarray:
7373 )
7474 # Decode the differences
7575 diffs = ans_decode(encoded)
76- # Create output array starting with x0
77- result = np.empty(len(diffs) + 1, dtype=diffs.dtype)
78- result[0] = x0
79- # Compute cumulative sum of differences
80- np.cumsum(diffs, out=result[1:])
81- return result
76+ # Insert x0 at the beginning and cumulatively sum the differences
77+ return np.cumsum(np.insert(diffs, 0, x0))
8278
8379
8480 def simple_ans_encode(x: np.ndarray) -> bytes:
moveopenescclose