/ proof-of-concept / benchcompress
Sign in
proof-of-concept / benchcompress
rename ans
Jeremy Magland <jmagland@flatironinstitute.org> committed commit c1f542a9f600 parent c2458a2 Browse files
12 changed files+39−37
benchcompress/setup.pymodified+6−6View file
@@ -44,12 +44,12 @@ setup(
4444 "pybind11>=2.11.1"
4545 ],
4646 ext_modules=[
47- CMakeExtension("benchcompress.algorithms.simple_ans.markov_reconstruct_cpp_ext",
48- sourcedir="src/benchcompress/algorithms/simple_ans"),
49- CMakeExtension("benchcompress.algorithms.simple_ans.markov_predict_cpp_ext",
50- sourcedir="src/benchcompress/algorithms/simple_ans"),
51- CMakeExtension("benchcompress.algorithms.simple_ans.get_run_lengths_cpp_ext",
52- sourcedir="src/benchcompress/algorithms/simple_ans")
47+ CMakeExtension("benchcompress.algorithms.ans.markov_reconstruct_cpp_ext",
48+ sourcedir="src/benchcompress/algorithms/ans"),
49+ CMakeExtension("benchcompress.algorithms.ans.markov_predict_cpp_ext",
50+ sourcedir="src/benchcompress/algorithms/ans"),
51+ CMakeExtension("benchcompress.algorithms.ans.get_run_lengths_cpp_ext",
52+ sourcedir="src/benchcompress/algorithms/ans")
5353 ],
5454 cmdclass={
5555 "build_ext": CMakeBuild,
benchcompress/src/benchcompress/_compress_ints_lossless.pymodified+2−2View file
@@ -7,7 +7,7 @@ def compress_ints_lossless(x, *, method: str = "zstd") -> bytes:
77 - "zstd": Zstandard compression (default)
88 - "zlib": zlib compression
99 - "lzma": LZMA compression
10- - "simple_ans": Simple Asymmetric Numeral Systems
10+ - "ANS": Asymmetric Numeral Systems
1111
1212 Returns:
1313 Compressed bytes
@@ -25,7 +25,7 @@ def compress_ints_lossless(x, *, method: str = "zstd") -> bytes:
2525 import lzma
2626
2727 return lzma.compress(x.tobytes(), preset=9)
28- elif method == "simple_ans":
28+ elif method == "ANS":
2929 from simple_ans import ans_encode
3030
3131 encoding = ans_encode(x)
benchcompress/src/benchcompress/algorithms/__init__.pymodified+2−2View file
@@ -1,13 +1,13 @@
11 from .zlib import algorithms as zlib_algorithms
22 from .zstd import algorithms as zstd_algorithms
3-from .simple_ans import algorithms as simple_ans_algorithms
3+from .ans import algorithms as ans_algorithms
44 from .lzma import algorithms as lzma_algorithms
55 from .brotli import algorithms as brotli_algorithms
66
77 algorithms = (
88 zlib_algorithms
99 + zstd_algorithms
10- + simple_ans_algorithms
10+ + ans_algorithms
1111 + lzma_algorithms
1212 + brotli_algorithms
1313 )
benchcompress/src/benchcompress/algorithms/simple_ans/CMakeLists.txt →benchcompress/src/benchcompress/algorithms/ans/CMakeLists.txtrenamed+1−1View file
@@ -36,4 +36,4 @@ pybind11_add_module(get_run_lengths_cpp_ext get_run_lengths.cpp)
3636
3737 # Install all modules
3838 install(TARGETS markov_reconstruct_cpp_ext markov_predict_cpp_ext get_run_lengths_cpp_ext
39- DESTINATION benchcompress/algorithms/simple_ans)
39+ DESTINATION benchcompress/algorithms/ans)
benchcompress/src/benchcompress/algorithms/simple_ans/__init__.py →benchcompress/src/benchcompress/algorithms/ans/__init__.pyrenamed+26−26View file
@@ -7,10 +7,10 @@ from .markov_predict import (
77 )
88 from .get_run_lengths import get_run_lengths
99
10-SOURCE_FILE = "simple_ans/__init__.py"
10+SOURCE_FILE = "ans/__init__.py"
1111
1212
13-def simple_ans_encode(x: np.ndarray) -> bytes:
13+def ans_encode(x: np.ndarray) -> bytes:
1414 from simple_ans import ans_encode
1515
1616 assert x.ndim == 1
@@ -43,7 +43,7 @@ def simple_ans_encode(x: np.ndarray) -> bytes:
4343 return header_size.tobytes() + header_bytes + encoded.bitstream
4444
4545
46-def simple_ans_decode(x: bytes, dtype: str) -> np.ndarray:
46+def ans_decode(x: bytes, dtype: str) -> np.ndarray:
4747 from simple_ans import ans_decode, EncodedSignal
4848
4949 header_size = np.frombuffer(x[:4], dtype=np.uint32)[0]
@@ -76,7 +76,7 @@ def simple_ans_decode(x: bytes, dtype: str) -> np.ndarray:
7676 return ans_decode(encoded)
7777
7878
79-def simple_ans_delta_encode(x: np.ndarray) -> bytes:
79+def ans_delta_encode(x: np.ndarray) -> bytes:
8080 from simple_ans import ans_encode
8181
8282 assert x.ndim == 1
@@ -113,7 +113,7 @@ def simple_ans_delta_encode(x: np.ndarray) -> bytes:
113113 return header_size.tobytes() + header_bytes + encoded.bitstream
114114
115115
116-def simple_ans_delta_decode(x: bytes, dtype: str) -> np.ndarray:
116+def ans_delta_decode(x: bytes, dtype: str) -> np.ndarray:
117117 from simple_ans import ans_decode, EncodedSignal
118118
119119 header_size = np.frombuffer(x[:4], dtype=np.uint32)[0]
@@ -151,7 +151,7 @@ def simple_ans_delta_decode(x: bytes, dtype: str) -> np.ndarray:
151151 return np.cumsum(np.insert(diffs, 0, x0))
152152
153153
154-def simple_ans_markov_encode(x: np.ndarray) -> bytes:
154+def ans_markov_encode(x: np.ndarray) -> bytes:
155155 from simple_ans import ans_encode
156156
157157 assert x.ndim == 1
@@ -191,7 +191,7 @@ def simple_ans_markov_encode(x: np.ndarray) -> bytes:
191191 return header_size.tobytes() + header_bytes + encoded.bitstream
192192
193193
194-def simple_ans_markov_decode(x: bytes, dtype: str) -> np.ndarray:
194+def ans_markov_decode(x: bytes, dtype: str) -> np.ndarray:
195195 from simple_ans import ans_decode, EncodedSignal
196196
197197 header_size = np.frombuffer(x[:4], dtype=np.uint32)[0]
@@ -245,7 +245,7 @@ def simple_ans_markov_decode(x: bytes, dtype: str) -> np.ndarray:
245245 return output
246246
247247
248-def simple_ans_markov_sparse_encode(x: np.ndarray) -> bytes:
248+def ans_markov_sparse_encode(x: np.ndarray) -> bytes:
249249 from simple_ans import ans_encode
250250
251251 assert x.ndim == 1
@@ -321,7 +321,7 @@ def simple_ans_markov_sparse_encode(x: np.ndarray) -> bytes:
321321 )
322322
323323
324-def simple_ans_markov_sparse_decode(x: bytes, dtype: str) -> np.ndarray:
324+def ans_markov_sparse_decode(x: bytes, dtype: str) -> np.ndarray:
325325 from simple_ans import ans_decode, EncodedSignal
326326
327327 header_size = np.frombuffer(x[:4], dtype=np.uint32)[0]
@@ -429,39 +429,39 @@ def simple_ans_markov_sparse_decode(x: bytes, dtype: str) -> np.ndarray:
429429
430430 algorithms = [
431431 {
432- "name": "simple-ans",
432+ "name": "ANS",
433433 "version": "3",
434- "encode": lambda x: simple_ans_encode(x),
435- "decode": lambda x, dtype: simple_ans_decode(x, dtype),
436- "description": "Basic Asymmetric Numeral Systems (ANS) entropy coding for efficient data compression.",
434+ "encode": lambda x: ans_encode(x),
435+ "decode": lambda x, dtype: ans_decode(x, dtype),
436+ "description": "ANS compression via simple_ans for efficient data compression.",
437437 "tags": ["ANS"],
438438 "source_file": SOURCE_FILE,
439439 },
440440 {
441- "name": "simple-ans-delta",
441+ "name": "ANS-delta",
442442 "version": "3",
443- "encode": lambda x: simple_ans_delta_encode(x),
444- "decode": lambda x, dtype: simple_ans_delta_decode(x, dtype),
445- "description": "ANS compression with delta encoding for improved compression of sequential data.",
443+ "encode": lambda x: ans_delta_encode(x),
444+ "decode": lambda x, dtype: ans_delta_decode(x, dtype),
445+ "description": "ANS compression via simple_ans with delta encoding for improved compression of sequential data.",
446446 "tags": ["ANS", "delta_encoding"],
447447 "source_file": SOURCE_FILE,
448448 },
449449 {
450- "name": "simple-ans-markov",
450+ "name": "ANS-markov",
451451 "version": "6",
452- "encode": lambda x: simple_ans_markov_encode(x),
453- "decode": lambda x, dtype: simple_ans_markov_decode(x, dtype),
454- "description": "ANS compression with Markov prediction for exploiting temporal correlations in the data.",
452+ "encode": lambda x: ans_markov_encode(x),
453+ "decode": lambda x, dtype: ans_markov_decode(x, dtype),
454+ "description": "ANS compression via simple_ans with Markov prediction for exploiting temporal correlations in the data.",
455455 "tags": ["ANS", "markov_prediction"],
456456 "source_file": SOURCE_FILE,
457457 },
458458 {
459- "name": "simple-ans-markov-sparse",
459+ "name": "ANS-markov-zrle",
460460 "version": "6",
461- "encode": lambda x: simple_ans_markov_sparse_encode(x),
462- "decode": lambda x, dtype: simple_ans_markov_sparse_decode(x, dtype),
463- "description": "ANS compression with Markov prediction and run-length encoding for sparse data.",
464- "tags": ["ANS", "markov_prediction", "run_length_encoding"],
461+ "encode": lambda x: ans_markov_sparse_encode(x),
462+ "decode": lambda x, dtype: ans_markov_sparse_decode(x, dtype),
463+ "description": "ANS compression via simple_ans with Markov prediction and zero run-length encoding for sparse data.",
464+ "tags": ["ANS", "markov_prediction", "zero_rle"],
465465 "source_file": SOURCE_FILE,
466466 },
467467 ]
benchcompress/src/benchcompress/algorithms/simple_ans/get_run_lengths.cpp →benchcompress/src/benchcompress/algorithms/ans/get_run_lengths.cpprenamed+0−0View file
No changes to the file's content.
benchcompress/src/benchcompress/algorithms/simple_ans/get_run_lengths.py →benchcompress/src/benchcompress/algorithms/ans/get_run_lengths.pyrenamed+0−0View file
No changes to the file's content.
benchcompress/src/benchcompress/algorithms/simple_ans/markov_predict.cpp →benchcompress/src/benchcompress/algorithms/ans/markov_predict.cpprenamed+0−0View file
No changes to the file's content.
benchcompress/src/benchcompress/algorithms/simple_ans/markov_predict.py →benchcompress/src/benchcompress/algorithms/ans/markov_predict.pyrenamed+0−0View file
No changes to the file's content.
benchcompress/src/benchcompress/algorithms/simple_ans/markov_reconstruct.cpp →benchcompress/src/benchcompress/algorithms/ans/markov_reconstruct.cpprenamed+0−0View file
No changes to the file's content.
benchcompress/src/benchcompress/algorithms/simple_ans/markov_reconstruct.py →benchcompress/src/benchcompress/algorithms/ans/markov_reconstruct.pyrenamed+0−0View file
No changes to the file's content.
benchcompress/src/benchcompress/run_benchmarks.pymodified+2−0View file
@@ -35,6 +35,8 @@ def is_compatible(algorithm_tags: List[str], dataset_tags: List[str]) -> bool:
3535 return False
3636 if "markov_prediction" in algorithm_tags and "continuous" not in dataset_tags:
3737 return False
38+ if "zero_rle" in algorithm_tags and "sparse" not in dataset_tags:
39+ return False
3840 return True
3941
4042
↑↓ move↵openescclose