wavpack on unsigned
4 changed files+41−27
benchcompress/src/benchcompress/algorithms/wavpack/__init__.pymodified+8−0View file
@@ -18,6 +18,10 @@ LONG_DESCRIPTION = _load_long_description()
1818 def wavpack_encode(x: np.ndarray, level: int) -> bytes:
1919 from wavpack_numcodecs import WavPack
2020
21+ # if unsigned type, cast to signed
22+ if x.dtype.kind == "u":
23+ x = x.astype(np.int64) # Convert unsigned to signed
24+
2125 assert x.ndim == 1 or x.ndim == 2
2226 wv = WavPack(level=level)
2327 compressed = wv.encode(x)
@@ -30,6 +34,10 @@ def wavpack_decode(x: bytes, dtype: str, shape: tuple) -> np.ndarray:
3034 wv = WavPack()
3135 buf = wv.decode(x)
3236 y = np.frombuffer(buf, dtype=dtype)
37+
38+ # make sure the dtype matches the original
39+ y = y.astype(dtype)
40+
3341 return y.reshape(shape)
3442
3543
benchcompress/src/benchcompress/datasets/bernoulli/__init__.pymodified+1−10View file
@@ -21,16 +21,7 @@ def create_bernoulli(*, n_samples: int, p: float, seed: int) -> np.ndarray:
2121 return x
2222
2323
24-tags = [
25- "bernoulli",
26- "timeseries",
27- "1d",
28- "integer",
29- "discrete",
30- "synthetic",
31- "i.i.d.",
32- "unsigned",
33-]
24+tags = ["bernoulli", "timeseries", "1d", "integer", "discrete", "synthetic", "i.i.d."]
3425
3526 datasets = [
3627 {
benchcompress/src/benchcompress/run_benchmarks/is_compatible.pymodified+0−4View file
@@ -35,8 +35,4 @@ def is_compatible(algorithm_tags: List[str], dataset_tags: List[str]) -> bool:
3535 if "integer" not in dataset_tags:
3636 return False
3737
38- if "signed_only" in algorithm_tags:
39- if "unsigned" in dataset_tags:
40- return False
41-
4238 return True
figures/make_figures_iid.pymodified+32−13View file
@@ -7,6 +7,22 @@ from matplotlib.axes import Axes
77 from adjustText import adjust_text
88 from load_results import download_results, load_results_into_models, BenchmarkResults
99
10+# Font size configurations
11+FONT_SIZES = {
12+ 'base': 14,
13+ 'title': 18,
14+ 'axis_label': 16,
15+ 'tick_label': 14,
16+ 'legend': 14,
17+ 'annotation': 14
18+}
19+
20+figheight = 9
21+figheight2 = 9
22+
23+# Set base font size for all plots
24+plt.rcParams.update({'font.size': FONT_SIZES['base']})
25+
1026 def ensure_image_dir():
1127 """Ensure the images directory exists relative to this script."""
1228 script_dir = os.path.dirname(os.path.abspath(__file__))
@@ -62,9 +78,10 @@ def plot_single_compression_ratio_comparison(results: BenchmarkResults, dataset_
6278
6379 # Create horizontal bar plot
6480 ax.barh(algorithms, ratios)
65- ax.set_xlabel('Compression Ratio')
66- ax.set_ylabel('Algorithm')
67- ax.set_title(f'Compression Ratios for {dataset_name}')
81+ ax.set_xlabel('Compression Ratio', fontsize=FONT_SIZES['axis_label'])
82+ ax.set_ylabel('Algorithm', fontsize=FONT_SIZES['axis_label'])
83+ ax.set_title(f'Compression Ratios for {dataset_name}', fontsize=FONT_SIZES['title'])
84+ ax.tick_params(axis='both', which='major', labelsize=FONT_SIZES['tick_label'])
6885
6986 # Add theoretical limit line if applicable
7087 theoretical_ratio = get_theoretical_ratio(dataset_name)
@@ -77,7 +94,7 @@ def figure_tradeoff_comparison(results: BenchmarkResults, datasets: list[str]):
7794 # Create two figures - one for encode, one for decode
7895 for speed_type in ['encode', 'decode']:
7996 n_plots = len(datasets)
80- fig, axes = plt.subplots(1, n_plots, figsize=(10*n_plots, 8))
97+ fig, axes = plt.subplots(1, n_plots, figsize=(10*n_plots, figheight2))
8198 fig.suptitle(f'Compression Ratio vs {speed_type.capitalize()} Speed Tradeoff')
8299
83100 # Handle single dataset case
@@ -116,16 +133,17 @@ def figure_tradeoff_comparison(results: BenchmarkResults, datasets: list[str]):
116133 # Create scatter plot
117134 ax.scatter(ratios, speeds, alpha=0.6)
118135
119- texts = [ax.text(ratios[i], speeds[i], alg, fontsize=9) for i, alg in enumerate(algorithms)]
136+ texts = [ax.text(ratios[i], speeds[i], alg, fontsize=FONT_SIZES['annotation']) for i, alg in enumerate(algorithms)]
120137 adjust_text(texts,
121138 arrowprops=dict(arrowstyle='->', color='gray', linewidth=0.5),
122139 ensure_inside_axes=False,
123140 ax=ax)
124141
125142 # Customize plot
126- ax.set_xlabel('Compression Ratio (higher is better)')
127- ax.set_ylabel(f'{speed_type.capitalize()} Speed MB/sec (higher is better)')
128- ax.set_title(f'{dataset_name}')
143+ ax.set_xlabel('Compression Ratio (higher is better)', fontsize=FONT_SIZES['axis_label'])
144+ ax.set_ylabel(f'{speed_type.capitalize()} Speed MB/sec (higher is better)', fontsize=FONT_SIZES['axis_label'])
145+ ax.set_title(f'{dataset_name}', fontsize=FONT_SIZES['title'])
146+ ax.tick_params(axis='both', which='major', labelsize=FONT_SIZES['tick_label'])
129147 ax.grid(True, alpha=0.3)
130148
131149 # Add theoretical limit line if applicable
@@ -143,7 +161,7 @@ def figure_speeds_comparison(results: BenchmarkResults, datasets: list[str]):
143161 """Create horizontal bar plots comparing encode/decode speeds for the given datasets."""
144162 # Create figure with enough subplots for all datasets
145163 n_plots = len(datasets)
146- fig, axes = plt.subplots(1, n_plots, figsize=(10*n_plots, 6))
164+ fig, axes = plt.subplots(1, n_plots, figsize=(10*n_plots, figheight))
147165
148166 # Handle single dataset case
149167 if n_plots == 1:
@@ -191,9 +209,10 @@ def figure_speeds_comparison(results: BenchmarkResults, datasets: list[str]):
191209 # Customize plot
192210 ax.set_yticks(y_pos)
193211 ax.set_yticklabels(algorithms)
194- ax.set_xlabel('Speed (MB/sec)')
195- ax.set_title(f'Encode/Decode Speeds for {dataset_name}')
196- ax.legend()
212+ ax.set_xlabel('Speed (MB/sec)', fontsize=FONT_SIZES['axis_label'])
213+ ax.set_title(f'Encode/Decode Speeds for {dataset_name}', fontsize=FONT_SIZES['title'])
214+ ax.tick_params(axis='both', which='major', labelsize=FONT_SIZES['tick_label'])
215+ ax.legend(fontsize=FONT_SIZES['legend'])
197216
198217 # Add grid for readability
199218 ax.grid(True, axis='x', alpha=0.3)
@@ -207,7 +226,7 @@ def figure_compression_ratios_comparison(results: BenchmarkResults, datasets: li
207226 """Create horizontal bar plots comparing compression ratios for given datasets."""
208227 # Create figure with enough subplots for all datasets
209228 n_plots = len(datasets)
210- fig, axes = plt.subplots(1, n_plots, figsize=(10*n_plots, 6))
229+ fig, axes = plt.subplots(1, n_plots, figsize=(10*n_plots, figheight))
211230
212231 # Handle single dataset case
213232 if n_plots == 1: