misc updates
24 changed files+244−64
benchcompress/src/benchcompress/algorithms/__init__.pymodified+2−1View file
@@ -7,8 +7,9 @@ from .brotli import algorithms as brotli_algorithms
77 from .lz4 import algorithms as lz4_algorithms
88 from .blosc2 import algorithms as blosc2_algorithms
99 from .wavpack import algorithms as wavpack_algorithms
10+from ..types import Algorithm
1011
11-algorithms = (
12+algorithms: list[Algorithm] = (
1213 bzip2_algorithms
1314 + zlib_algorithms
1415 + zstd_algorithms
benchcompress/src/benchcompress/algorithms/ans/__init__.pymodified+7−1View file
@@ -16,6 +16,7 @@ from .header_utils import (
1616 create_lpc_sparse_header,
1717 unpack_lpc_sparse_header,
1818 )
19+from ...types import Algorithm
1920
2021
2122 SOURCE_FILE = "ans/__init__.py"
@@ -444,7 +445,7 @@ def ans_lpc_sparse_decode(x: bytes, dtype: str, shape: tuple) -> np.ndarray:
444445 return output
445446
446447
447-algorithms = [
448+algorithms_dicts = [
448449 {
449450 "name": "ANS",
450451 "version": "11",
@@ -486,3 +487,8 @@ algorithms = [
486487 "long_description": LONG_DESCRIPTION,
487488 },
488489 ]
490+
491+algorithms = [
492+ Algorithm(**a)
493+ for a in algorithms_dicts
494+]
benchcompress/src/benchcompress/algorithms/blosc2/__init__.pymodified+7−1View file
@@ -3,6 +3,7 @@ import os
33 from ..ans.lpc_reconstruct import lpc_reconstruct as lpc_reconstruct_cpp
44 from ..ans.lpc_predict import lpc_predict as lpc_predict_cpp
55 from ..ans.get_run_lengths import get_run_lengths
6+from ...types import Algorithm
67
78 SOURCE_FILE = "blosc2/__init__.py"
89
@@ -282,7 +283,7 @@ def blosc2_lpc_zrle_decode(x: bytes, dtype: str, shape: tuple) -> np.ndarray:
282283 return np.concatenate(segments)
283284
284285
285-algorithms = [
286+algorithms_dicts = [
286287 {
287288 "name": "blosc2-1",
288289 "version": "1b",
@@ -364,3 +365,8 @@ algorithms = [
364365 "long_description": LONG_DESCRIPTION,
365366 },
366367 ]
368+
369+algorithms = [
370+ Algorithm(**a)
371+ for a in algorithms_dicts
372+]
benchcompress/src/benchcompress/algorithms/brotli/__init__.pymodified+7−1View file
@@ -1,6 +1,7 @@
11 import numpy as np
22 import brotli
33 import os
4+from ...types import Algorithm
45
56
67 SOURCE_FILE = "brotli/__init__.py"
@@ -44,7 +45,7 @@ def brotli_decode(x: bytes, dtype: str, shape: tuple) -> np.ndarray:
4445 return y.reshape(shape)
4546
4647
47-algorithms = [
48+algorithms_dicts = [
4849 {
4950 "name": "brotli-4",
5051 "version": "1",
@@ -96,3 +97,8 @@ algorithms = [
9697 "long_description": LONG_DESCRIPTION,
9798 },
9899 ]
100+
101+algorithms = [
102+ Algorithm(**a)
103+ for a in algorithms_dicts
104+]
benchcompress/src/benchcompress/algorithms/bzip2/__init__.pymodified+8−1View file
@@ -1,5 +1,6 @@
11 import numpy as np
22 import os
3+from ...types import Algorithm
34
45
56 SOURCE_FILE = "bzip2/__init__.py"
@@ -52,7 +53,7 @@ def bzip2_delta_decode(x: bytes, dtype: str, shape: tuple) -> np.ndarray:
5253 return np.cumsum(y)
5354
5455
55-algorithms = [
56+algorithms_dicts = [
5657 {
5758 "name": "bzip2-1",
5859 "version": "1",
@@ -114,3 +115,9 @@ algorithms = [
114115 "long_description": LONG_DESCRIPTION,
115116 },
116117 ]
118+
119+
120+algorithms = [
121+ Algorithm(**a)
122+ for a in algorithms_dicts
123+]
benchcompress/src/benchcompress/algorithms/lz4/__init__.pymodified+8−1View file
@@ -1,5 +1,6 @@
11 import numpy as np
22 import os
3+from ...types import Algorithm
34
45
56 SOURCE_FILE = "lz4/__init__.py"
@@ -52,7 +53,7 @@ def lz4_delta_decode(x: bytes, dtype: str, shape: tuple) -> np.ndarray:
5253 return np.cumsum(y)
5354
5455
55-algorithms = [
56+algorithms_dicts = [
5657 {
5758 "name": "lz4-0",
5859 "version": "1",
@@ -104,3 +105,9 @@ algorithms = [
104105 "long_description": LONG_DESCRIPTION,
105106 },
106107 ]
108+
109+
110+algorithms = [
111+ Algorithm(**a)
112+ for a in algorithms_dicts
113+]
benchcompress/src/benchcompress/algorithms/lzma/__init__.pymodified+8−1View file
@@ -1,5 +1,6 @@
11 import numpy as np
22 import os
3+from ...types import Algorithm
34
45
56 SOURCE_FILE = "lzma/__init__.py"
@@ -52,7 +53,7 @@ def lzma_decode(x: bytes, dtype: str, shape: tuple) -> np.ndarray:
5253 return y.reshape(shape)
5354
5455
55-algorithms = [
56+algorithms_dicts = [
5657 {
5758 "name": "lzma-9",
5859 "version": "1",
@@ -74,3 +75,9 @@ algorithms = [
7475 "long_description": LONG_DESCRIPTION,
7576 },
7677 ]
78+
79+
80+algorithms = [
81+ Algorithm(**a)
82+ for a in algorithms_dicts
83+]
benchcompress/src/benchcompress/algorithms/wavpack/__init__.pymodified+8−1View file
@@ -1,5 +1,6 @@
11 import numpy as np
22 import os
3+from ...types import Algorithm
34
45
56 SOURCE_FILE = "wavpack/__init__.py"
@@ -45,7 +46,7 @@ def wavpack_decode(x: bytes, dtype: str, shape: tuple) -> np.ndarray:
4546 return y.reshape(shape)
4647
4748
48-algorithms = [
49+algorithms_dicts = [
4950 {
5051 "name": "wavpack-1",
5152 "version": "1",
@@ -87,3 +88,9 @@ algorithms = [
8788 "long_description": LONG_DESCRIPTION,
8889 },
8990 ]
91+
92+
93+algorithms = [
94+ Algorithm(**a)
95+ for a in algorithms_dicts
96+]
benchcompress/src/benchcompress/algorithms/zlib/__init__.pymodified+8−1View file
@@ -1,5 +1,6 @@
11 import numpy as np
22 import os
3+from ...types import Algorithm
34
45
56 SOURCE_FILE = "zlib/__init__.py"
@@ -52,7 +53,7 @@ def zlib_delta_decode(x: bytes, dtype: str, shape: tuple) -> np.ndarray:
5253 return np.cumsum(y)
5354
5455
55-algorithms = [
56+algorithms_dicts = [
5657 {
5758 "name": "zlib-1",
5859 "version": "1",
@@ -114,3 +115,9 @@ algorithms = [
114115 "long_description": LONG_DESCRIPTION,
115116 },
116117 ]
118+
119+
120+algorithms = [
121+ Algorithm(**a)
122+ for a in algorithms_dicts
123+]
benchcompress/src/benchcompress/algorithms/zstd/__init__.pymodified+8−1View file
@@ -3,6 +3,7 @@ import os
33 from ..ans.lpc_reconstruct import lpc_reconstruct as lpc_reconstruct_cpp
44 from ..ans.lpc_predict import lpc_predict as lpc_predict_cpp
55 from ..ans.get_run_lengths import get_run_lengths
6+from ...types import Algorithm
67
78
89 SOURCE_FILE = "zstd/__init__.py"
@@ -232,7 +233,7 @@ def zstd_lpc_zrle_decode(x: bytes, dtype: str, shape: tuple) -> np.ndarray:
232233 return np.concatenate(segments)
233234
234235
235-algorithms = [
236+algorithms_dicts = [
236237 {
237238 "name": "zstd-4",
238239 "version": "1",
@@ -334,3 +335,9 @@ algorithms = [
334335 "long_description": LONG_DESCRIPTION,
335336 },
336337 ]
338+
339+
340+algorithms = [
341+ Algorithm(**a)
342+ for a in algorithms_dicts
343+]
benchcompress/src/benchcompress/cli.pymodified+8−8View file
@@ -9,26 +9,26 @@ from .datasets import datasets
99
1010 def get_available_algorithms() -> List[str]:
1111 """Get list of available algorithm names"""
12- return [alg["name"] for alg in algorithms]
12+ return [alg.name for alg in algorithms]
1313
1414
1515 def get_available_datasets() -> List[str]:
1616 """Get list of available dataset names"""
17- return [ds["name"] for ds in datasets]
17+ return [ds.name for ds in datasets]
1818
1919
2020 def filter_algorithms(selected: Optional[List[str]] = None) -> List[dict]:
2121 """Filter algorithms based on selected names"""
2222 if not selected:
2323 return algorithms
24- return [alg for alg in algorithms if alg["name"] in selected]
24+ return [alg for alg in algorithms if alg.name in selected]
2525
2626
2727 def filter_datasets(selected: Optional[List[str]] = None) -> List[dict]:
2828 """Filter datasets based on selected names"""
2929 if not selected:
3030 return datasets
31- return [ds for ds in datasets if ds["name"] in selected]
31+ return [ds for ds in datasets if ds.name in selected]
3232
3333
3434 def validate_algorithms(ctx, param, value):
@@ -68,13 +68,13 @@ def list():
6868 """List available algorithms and datasets"""
6969 click.echo("\nAvailable Algorithms:")
7070 for alg in algorithms:
71- desc = alg.get("description", "No description")
72- click.echo(f" {alg['name']:<20} - {desc}")
71+ desc = alg.description if alg.description else "No description"
72+ click.echo(f" {alg.name:<20} - {desc}")
7373
7474 click.echo("\nAvailable Datasets:")
7575 for ds in datasets:
76- desc = ds.get("description", "No description")
77- click.echo(f" {ds['name']:<20} - {desc}")
76+ desc = ds.description if ds.description else "No description"
77+ click.echo(f" {ds.name:<20} - {desc}")
7878
7979
8080 @cli.command()
benchcompress/src/benchcompress/datasets/__init__.pymodified+2−1View file
@@ -6,6 +6,7 @@ from .ecephys import datasets as ecephys_datasets
66 from .seismic import datasets as seismic_datasets
77 from .ieeg import datasets as ieeg_datasets
88 from .fmri import datasets as fmri_datasets
9+from ..types import Dataset
910
1011 datasets_list = [
1112 bernoulli_datasets,
@@ -18,6 +19,6 @@ datasets_list = [
1819 fmri_datasets,
1920 ]
2021
21-datasets = []
22+datasets: list[Dataset] = []
2223 for d in datasets_list:
2324 datasets.extend(d)
benchcompress/src/benchcompress/datasets/bernoulli/__init__.pymodified+22−1View file
@@ -1,5 +1,6 @@
11 import numpy as np
22 import os
3+from ...types import Dataset
34
45
56 SOURCE_FILE = "bernoulli/__init__.py"
@@ -20,10 +21,19 @@ def create_bernoulli(*, n_samples: int, p: float, seed: int) -> np.ndarray:
2021 x = rng.binomial(1, p, n_samples).astype(np.uint8)
2122 return x
2223
24+def _ideal_compression_ratio_for_p(p: float) -> float:
25+ """Calculate the ideal compression ratio for a Bernoulli distribution with parameter p."""
26+ if p <= 0 or p >= 1:
27+ return float('inf') # No uncertainty, infinite compression possible
28+ import math
29+ H = -p * math.log2(p) - (1 - p) * math.log2(1 - p) # Entropy in bits
30+ ideal_ratio = 8 / H # Since each sample is stored in 8 bits (1 byte)
31+ return ideal_ratio
32+
2333
2434 tags = ["bernoulli", "timeseries", "1d", "integer", "discrete", "synthetic", "i.i.d."]
2535
26-datasets = [
36+datasets_dicts = [
2737 {
2838 "name": "bernoulli-0.1",
2939 "version": "3c",
@@ -32,6 +42,7 @@ datasets = [
3242 "tags": tags,
3343 "source_file": SOURCE_FILE,
3444 "long_description": LONG_DESCRIPTION,
45+ 'ideal_compression_ratio': _ideal_compression_ratio_for_p(0.1),
3546 },
3647 {
3748 "name": "bernoulli-0.2",
@@ -41,6 +52,7 @@ datasets = [
4152 "tags": tags,
4253 "source_file": SOURCE_FILE,
4354 "long_description": LONG_DESCRIPTION,
55+ 'ideal_compression_ratio': _ideal_compression_ratio_for_p(0.2),
4456 },
4557 {
4658 "name": "bernoulli-0.3",
@@ -50,6 +62,7 @@ datasets = [
5062 "tags": tags,
5163 "source_file": SOURCE_FILE,
5264 "long_description": LONG_DESCRIPTION,
65+ 'ideal_compression_ratio': _ideal_compression_ratio_for_p(0.3),
5366 },
5467 {
5568 "name": "bernoulli-0.4",
@@ -59,6 +72,7 @@ datasets = [
5972 "tags": tags,
6073 "source_file": SOURCE_FILE,
6174 "long_description": LONG_DESCRIPTION,
75+ 'ideal_compression_ratio': _ideal_compression_ratio_for_p(0.4),
6276 },
6377 {
6478 "name": "bernoulli-0.5",
@@ -68,5 +82,12 @@ datasets = [
6882 "tags": tags,
6983 "source_file": SOURCE_FILE,
7084 "long_description": LONG_DESCRIPTION,
85+ 'ideal_compression_ratio': _ideal_compression_ratio_for_p(0.5),
7186 },
7287 ]
88+
89+
90+datasets = [
91+ Dataset(**a)
92+ for a in datasets_dicts
93+]
benchcompress/src/benchcompress/datasets/ecephys/__init__.pymodified+8−1View file
@@ -4,6 +4,7 @@ import os
44 from typing import cast
55 from ..._filters import bandpass_filter
66 from ..._analysis import estimate_noise_level
7+from ...types import Dataset
78
89
910 SOURCE_FILE = "ecephys/__init__.py"
@@ -200,7 +201,7 @@ def _create_sparse_version(X: np.ndarray) -> np.ndarray:
200201 return X3
201202
202203
203-datasets = [
204+datasets_dicts = [
204205 {
205206 "name": "ecephys-000876-ch45",
206207 "version": "1",
@@ -347,3 +348,9 @@ datasets = [
347348 # "long_description": LONG_DESCRIPTION,
348349 # },
349350 ]
351+
352+
353+datasets = [
354+ Dataset(**a)
355+ for a in datasets_dicts
356+]
benchcompress/src/benchcompress/datasets/fmri/__init__.pymodified+8−1View file
@@ -2,6 +2,7 @@ import numpy as np
22 import os
33 import nibabel as nib
44 from typing import cast, Optional, List
5+from ...types import Dataset
56
67 SOURCE_FILE = "fmri/__init__.py"
78
@@ -58,7 +59,7 @@ def _load_bold_data(*, slice_indices: Optional[List[int]] = None) -> np.ndarray:
5859 return data
5960
6061
61-datasets = [
62+datasets_dicts = [
6263 {
6364 "name": "fmri-ds005880",
6465 "version": "2",
@@ -69,3 +70,9 @@ datasets = [
6970 "long_description": LONG_DESCRIPTION,
7071 }
7172 ]
73+
74+
75+datasets = [
76+ Dataset(**a)
77+ for a in datasets_dicts
78+]
benchcompress/src/benchcompress/datasets/gaussian/__init__.pymodified+8−1View file
@@ -1,5 +1,6 @@
11 import numpy as np
22 import os
3+from ...types import Dataset
34
45
56 SOURCE_FILE = "gaussian/__init__.py"
@@ -40,7 +41,7 @@ tags_quantized = [
4041 ]
4142 tags_float = ["gaussian", "float", "timeseries", "1d", "synthetic", "i.i.d."]
4243
43-datasets = [
44+datasets_dicts = [
4445 {
4546 "name": "gaussian-q1",
4647 "version": "1",
@@ -106,3 +107,9 @@ datasets = [
106107 "long_description": LONG_DESCRIPTION,
107108 },
108109 ]
110+
111+
112+datasets = [
113+ Dataset(**a)
114+ for a in datasets_dicts
115+]
benchcompress/src/benchcompress/datasets/gaussian_ar1/__init__.pymodified+8−1View file
@@ -1,5 +1,6 @@
11 import numpy as np
22 import os
3+from ...types import Dataset
34
45 SOURCE_FILE = "gaussian_ar1/__init__.py"
56
@@ -49,7 +50,7 @@ tags = [
4950 "correlated",
5051 ]
5152
52-datasets = [
53+datasets_dicts = [
5354 {
5455 "name": "gaussian-ar1-02",
5556 "version": "1",
@@ -84,3 +85,9 @@ datasets = [
8485 "long_description": LONG_DESCRIPTION,
8586 },
8687 ]
88+
89+
90+datasets = [
91+ Dataset(**a)
92+ for a in datasets_dicts
93+]
benchcompress/src/benchcompress/datasets/gaussian_lowpass/__init__.pymodified+8−1View file
@@ -1,5 +1,6 @@
11 import numpy as np
22 import os
3+from ...types import Dataset
34
45 SOURCE_FILE = "gaussian_lowpass/__init__.py"
56
@@ -52,7 +53,7 @@ tags = [
5253 "filtered",
5354 ]
5455
55-datasets = [
56+datasets_dicts = [
5657 {
5758 "name": "gaussian-lp-03",
5859 "version": "1",
@@ -87,3 +88,9 @@ datasets = [
8788 "long_description": LONG_DESCRIPTION,
8889 },
8990 ]
91+
92+
93+datasets = [
94+ Dataset(**a)
95+ for a in datasets_dicts
96+]
benchcompress/src/benchcompress/datasets/ieeg/__init__.pymodified+8−1View file
@@ -2,6 +2,7 @@ import numpy as np
22 import os
33 import requests
44 import pyedflib
5+from ...types import Dataset
56
67 SOURCE_FILE = "ieeg/__init__.py"
78
@@ -63,7 +64,7 @@ def _load_quantized_ieeg_openneuro_005592() -> np.ndarray:
6364 return X
6465
6566
66-datasets = [
67+datasets_dicts = [
6768 {
6869 "name": "ieeg-005592",
6970 "version": "1",
@@ -83,3 +84,9 @@ datasets = [
8384 "long_description": LONG_DESCRIPTION,
8485 },
8586 ]
87+
88+
89+datasets = [
90+ Dataset(**a)
91+ for a in datasets_dicts
92+]
benchcompress/src/benchcompress/datasets/seismic/__init__.pymodified+8−1View file
@@ -2,6 +2,7 @@ import numpy as np
22 import segyio
33 import os
44 import requests
5+from ...types import Dataset
56
67
78 SOURCE_FILE = "seismic/__init__.py"
@@ -65,7 +66,7 @@ def _load_quantized_04A_04B_seismic_data():
6566 return X
6667
6768
68-datasets = [
69+datasets_dicts = [
6970 {
7071 "name": "seismic-04A-04B",
7172 "version": "1",
@@ -85,3 +86,9 @@ datasets = [
8586 "long_description": LONG_DESCRIPTION,
8687 },
8788 ]
89+
90+
91+datasets = [
92+ Dataset(**a)
93+ for a in datasets_dicts
94+]
benchcompress/src/benchcompress/run_benchmarks/collect_info.pymodified+15−14View file
@@ -1,11 +1,12 @@
11 from typing import List, Dict, Any
22 from ._memobin import construct_dataset_url
3+from ..types import Algorithm
34
45 GITHUB_ALGORITHMS_PREFIX = "https://github.com/magland/benchcompress/blob/main/benchcompress/src/benchcompress/algorithms/"
56 GITHUB_DATASETS_PREFIX = "https://github.com/magland/benchcompress/blob/main/benchcompress/src/benchcompress/datasets/"
67
78
8-def collect_algorithm_info(algorithms: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
9+def collect_algorithm_info(algorithms: List[Dict[str, Algorithm]]) -> List[Dict[str, Any]]:
910 """Collect information about compression algorithms.
1011
1112 Args:
@@ -17,11 +18,11 @@ def collect_algorithm_info(algorithms: List[Dict[str, Any]]) -> List[Dict[str, A
1718 algorithm_info = []
1819 for algorithm in algorithms:
1920 info = {
20- "name": algorithm["name"],
21- "description": algorithm.get("description", ""),
22- "long_description": algorithm.get("long_description", ""),
23- "version": algorithm["version"],
24- "tags": algorithm.get("tags", []),
21+ "name": algorithm.name,
22+ "description": algorithm.description if algorithm.description else "",
23+ "long_description": algorithm.long_description if algorithm.long_description else "",
24+ "version": algorithm.version,
25+ "tags": algorithm.tags if algorithm.tags else [],
2526 }
2627 if "source_file" in algorithm:
2728 info["source_file"] = GITHUB_ALGORITHMS_PREFIX + algorithm["source_file"]
@@ -41,19 +42,19 @@ def collect_dataset_info(datasets: List[Dict[str, Any]]) -> List[Dict[str, Any]]
4142 dataset_info = []
4243 for dataset in datasets:
4344 info = {
44- "name": dataset["name"],
45- "description": dataset.get("description", ""),
46- "long_description": dataset.get("long_description", ""),
47- "version": dataset["version"],
48- "tags": dataset.get("tags", []),
45+ "name": dataset.name,
46+ "description": dataset.description if dataset.description else "",
47+ "long_description": dataset.long_description if dataset.long_description else "",
48+ "version": dataset.version,
49+ "tags": dataset.tags if dataset.tags else [],
4950 "data_url_raw": construct_dataset_url(
50- dataset["name"], dataset["version"], "dat"
51+ dataset.name, dataset.version, "dat"
5152 ),
5253 "data_url_npy": construct_dataset_url(
53- dataset["name"], dataset["version"], "npy"
54+ dataset.name, dataset.version, "npy"
5455 ),
5556 "data_url_json": construct_dataset_url(
56- dataset["name"], dataset["version"], "json"
57+ dataset.name, dataset.version, "json"
5758 ),
5859 }
5960 if "source_file" in dataset:
benchcompress/src/benchcompress/run_benchmarks/run_benchmarks.pymodified+24−23View file
@@ -12,6 +12,7 @@ from .benchmark_timing import run_compression_benchmark
1212 from .collect_info import collect_algorithm_info, collect_dataset_info
1313 from .is_compatible import is_compatible
1414 from .upload_benchmark_status import upload_benchmark_status
15+from ..types import Algorithm, Dataset
1516
1617 system_version = "v6"
1718
@@ -19,8 +20,8 @@ system_version = "v6"
1920 def run_benchmarks(
2021 cache_dir: str = ".benchmark_cache",
2122 verbose: bool = True,
22- selected_algorithms: Optional[List[dict]] = None,
23- selected_datasets: Optional[List[dict]] = None,
23+ selected_algorithms: Optional[List[Algorithm]] = None,
24+ selected_datasets: Optional[List[Dataset]] = None,
2425 force: bool = False,
2526 ) -> Dict[str, Any]:
2627 """Run all benchmarks, with caching based on algorithm and dataset versions.
@@ -63,7 +64,7 @@ def run_benchmarks(
6364 1
6465 for dataset in datasets_to_run
6566 for algorithm in algorithms_to_run
66- if is_compatible(algorithm.get("tags", []), dataset.get("tags", []))
67+ if is_compatible(algorithm.tags, dataset.tags)
6768 )
6869
6970 # Run benchmarks for each dataset and algorithm combination
@@ -71,15 +72,15 @@ def run_benchmarks(
7172 upload_enabled = os.environ.get("UPLOAD_TO_MEMOBIN") == "1"
7273
7374 for dataset in datasets_to_run:
74- dataset_tags = dataset.get("tags", [])
75- print(f"\n*** Dataset: {dataset['name']} (tags: {dataset_tags}) ***")
75+ dataset_tags = dataset.tags
76+ print(f"\n*** Dataset: {dataset.name} (tags: {dataset_tags}) ***")
7677
7778 # only create the dataset if it is needed
7879 data = None
7980
8081 for algorithm in algorithms_to_run:
81- alg_name = algorithm["name"]
82- alg_tags = algorithm.get("tags", [])
82+ alg_name = algorithm.name
83+ alg_tags = algorithm.tags
8384
8485 # Skip if algorithm and dataset are not compatible based on tags
8586 if not is_compatible(alg_tags, dataset_tags):
@@ -89,7 +90,7 @@ def run_benchmarks(
8990 )
9091 continue
9192
92- print(f"\nTesting algorithm: {alg_name} on dataset: {dataset['name']}")
93+ print(f"\nTesting algorithm: {alg_name} on dataset: {dataset.name}")
9394
9495 # Upload current status to memobin if enabled (once per minute)
9596 current_time = time.time()
@@ -101,7 +102,7 @@ def run_benchmarks(
101102 try:
102103 upload_benchmark_status(
103104 memobin_api_key,
104- dataset["name"],
105+ dataset.name,
105106 alg_name,
106107 results,
107108 total_benchmarks,
@@ -114,10 +115,10 @@ def run_benchmarks(
114115 # Check if we can use cached result
115116 cached_result = check_cached_result(
116117 cache_dir,
117- dataset["name"],
118+ dataset.name,
118119 alg_name,
119- algorithm["version"],
120- dataset["version"],
120+ algorithm.version,
121+ dataset.version,
121122 system_version,
122123 force,
123124 verbose,
@@ -128,7 +129,7 @@ def run_benchmarks(
128129 results.append(cached_result)
129130 continue
130131
131- print(f" Running benchmark for {alg_name} on {dataset['name']}...")
132+ print(f" Running benchmark for {alg_name} on {dataset.name}...")
132133 if data is None:
133134 data = dataset["create"]()
134135 print(f"Created dataset: shape={data.shape}, dtype={data.dtype}")
@@ -140,8 +141,8 @@ def run_benchmarks(
140141 try:
141142 upload_dataset_to_memobin(
142143 data,
143- dataset["name"],
144- dataset["version"],
144+ dataset.name,
145+ dataset.version,
145146 memobin_api_key,
146147 cache_dir,
147148 verbose,
@@ -161,10 +162,10 @@ def run_benchmarks(
161162 # Add metadata to result
162163 result.update(
163164 {
164- "dataset": dataset["name"],
165+ "dataset": dataset.name,
165166 "algorithm": alg_name,
166- "algorithm_version": algorithm["version"],
167- "dataset_version": dataset["version"],
167+ "algorithm_version": algorithm.version,
168+ "dataset_version": dataset.version,
168169 "system_version": system_version,
169170 }
170171 )
@@ -175,11 +176,11 @@ def run_benchmarks(
175176 result,
176177 encoded,
177178 cache_dir,
178- dataset["name"],
179+ dataset.name,
179180 alg_name,
180181 )
181182 print(
182- f" Results saved to: {os.path.join(cache_dir, dataset['name'], alg_name)}"
183+ f" Results saved to: {os.path.join(cache_dir, dataset.name, alg_name)}"
183184 )
184185
185186 # Upload to memobin if enabled
@@ -187,9 +188,9 @@ def run_benchmarks(
187188 try:
188189 memobin_url = construct_memobin_url(
189190 alg_name,
190- dataset["name"],
191- algorithm["version"],
192- dataset["version"],
191+ dataset.name,
192+ algorithm.version,
193+ dataset.version,
193194 system_version,
194195 )
195196 upload_to_memobin(
benchcompress/src/benchcompress/types.pyadded+42−0View file
@@ -0,0 +1,42 @@
1+from typing import Callable
2+import numpy as np
3+
4+class Algorithm:
5+ def __init__(self, *,
6+ name: str,
7+ version: str,
8+ encode: Callable[[np.ndarray], bytes],
9+ decode: Callable[[bytes, np.dtype, tuple], np.ndarray],
10+ description: str,
11+ tags: list[str],
12+ source_file: str,
13+ long_description: str
14+ ):
15+ self.name = name
16+ self.version = version
17+ self.encode = encode
18+ self.decode = decode
19+ self.description = description
20+ self.tags = tags
21+ self.source_file = source_file
22+ self.long_description = long_description
23+
24+class Dataset:
25+ def __init__(self, *,
26+ name: str,
27+ version: str,
28+ create: Callable[[], np.ndarray],
29+ description: str,
30+ tags: list[str],
31+ source_file: str,
32+ long_description: str,
33+ ideal_compression_ratio: float = 0
34+ ):
35+ self.name = name
36+ self.version = version
37+ self.create = create
38+ self.description = description
39+ self.tags = tags
40+ self.source_file = source_file
41+ self.long_description = long_description
42+ self.ideal_compression_ratio = ideal_compression_ratio
devel/install_in_silverblue_toolbox.shadded+4−0View file
@@ -0,0 +1,4 @@
1+# Need to do this to allow it to find wavepack-numcodecs
2+export CFLAGS="-I/usr/include"
3+export LDFLAGS="-L/usr/lib64"
4+pip install -e .