links to source code
12 changed files+158−17
.vscode/tasks.jsonadded+19−0View file
@@ -0,0 +1,19 @@
1+{
2+ "version": "2.0.0",
3+ "tasks": [
4+ {
5+ "label": "Format Code",
6+ "type": "shell",
7+ "command": "./devel/format_code.sh",
8+ "group": {
9+ "kind": "build",
10+ "isDefault": true
11+ },
12+ "presentation": {
13+ "reveal": "always",
14+ "panel": "shared"
15+ },
16+ "problemMatcher": []
17+ }
18+ ]
19+}
web-ui/src/pages/Algorithms.tsxmodified+35−1View file
@@ -1,4 +1,5 @@
11 import { Algorithm } from "../types";
2+import { Link } from "react-router-dom";
23
34 interface AlgorithmsProps {
45 algorithms: Algorithm[];
@@ -57,6 +58,15 @@ function Algorithms({ algorithms }: AlgorithmsProps) {
5758 >
5859 Tags
5960 </th>
61+ <th
62+ style={{
63+ padding: "12px",
64+ textAlign: "left",
65+ borderBottom: "2px solid #ddd",
66+ }}
67+ >
68+ Source
69+ </th>
6070 </tr>
6171 </thead>
6272 <tbody>
@@ -68,7 +78,16 @@ function Algorithms({ algorithms }: AlgorithmsProps) {
6878 }}
6979 >
7080 <td style={{ padding: "12px", borderBottom: "1px solid #ddd" }}>
71- {algorithm.name}
81+ <Link
82+ to={`/home?algorithm=${encodeURIComponent(algorithm.name)}`}
83+ style={{
84+ color: "#0066cc",
85+ textDecoration: "none",
86+ fontWeight: "500",
87+ }}
88+ >
89+ {algorithm.name}
90+ </Link>
7291 </td>
7392 <td style={{ padding: "12px", borderBottom: "1px solid #ddd" }}>
7493 {algorithm.version}
@@ -93,6 +112,21 @@ function Algorithms({ algorithms }: AlgorithmsProps) {
93112 </span>
94113 ))}
95114 </td>
115+ <td style={{ padding: "12px", borderBottom: "1px solid #ddd" }}>
116+ {algorithm.source_file && (
117+ <a
118+ href={algorithm.source_file}
119+ target="_blank"
120+ rel="noopener noreferrer"
121+ style={{
122+ color: "#0066cc",
123+ textDecoration: "none",
124+ }}
125+ >
126+ View Source
127+ </a>
128+ )}
129+ </td>
96130 </tr>
97131 ))}
98132 </tbody>
web-ui/src/pages/Datasets.tsxmodified+24−0View file
@@ -58,6 +58,15 @@ function Datasets({ datasets }: DatasetsProps) {
5858 >
5959 Tags
6060 </th>
61+ <th
62+ style={{
63+ padding: "12px",
64+ textAlign: "left",
65+ borderBottom: "2px solid #ddd",
66+ }}
67+ >
68+ Source
69+ </th>
6170 </tr>
6271 </thead>
6372 <tbody>
@@ -103,6 +112,21 @@ function Datasets({ datasets }: DatasetsProps) {
103112 </span>
104113 ))}
105114 </td>
115+ <td style={{ padding: "12px", borderBottom: "1px solid #ddd" }}>
116+ {dataset.source_file && (
117+ <a
118+ href={dataset.source_file}
119+ target="_blank"
120+ rel="noopener noreferrer"
121+ style={{
122+ color: "#0066cc",
123+ textDecoration: "none",
124+ }}
125+ >
126+ View Source
127+ </a>
128+ )}
129+ </td>
106130 </tr>
107131 ))}
108132 </tbody>
web-ui/src/types.tsmodified+2−0View file
@@ -21,6 +21,7 @@ export interface Algorithm {
2121 description: string;
2222 version: string;
2323 tags: string[];
24+ source_file?: string;
2425 }
2526
2627 export interface Dataset {
@@ -28,6 +29,7 @@ export interface Dataset {
2829 description: string;
2930 version: string;
3031 tags: string[];
32+ source_file?: string;
3133 }
3234
3335 export interface BenchmarkData {
zia_benchmark/src/zia_benchmark/algorithms/lzma/__init__.pymodified+5−0View file
@@ -1,6 +1,9 @@
11 import numpy as np
22
33
4+SOURCE_FILE = "lzma/__init__.py"
5+
6+
47 def lzma_delta_encode(x: np.ndarray, preset: int) -> bytes:
58 import lzma
69
@@ -43,6 +46,7 @@ algorithms = [
4346 "version": "1",
4447 "encode": lambda x: lzma_encode(x, preset=9),
4548 "decode": lambda x, dtype: lzma_decode(x, dtype),
49+ "source_file": SOURCE_FILE,
4650 },
4751 {
4852 "name": "lzma-9-delta",
@@ -50,5 +54,6 @@ algorithms = [
5054 "encode": lambda x: lzma_delta_encode(x, preset=9),
5155 "decode": lambda x, dtype: lzma_delta_decode(x, dtype),
5256 "tags": ["delta_encoding"],
57+ "source_file": SOURCE_FILE,
5358 },
5459 ]
zia_benchmark/src/zia_benchmark/algorithms/simple_ans/__init__.pymodified+6−0View file
@@ -2,6 +2,9 @@ import numpy as np
22 from .markov import markov_predict, markov_reconstruct
33
44
5+SOURCE_FILE = "simple_ans/__init__.py"
6+
7+
58 def simple_ans_encode(x: np.ndarray) -> bytes:
69 from simple_ans import ans_encode
710
@@ -240,6 +243,7 @@ algorithms = [
240243 "version": "1",
241244 "encode": lambda x: simple_ans_encode(x),
242245 "decode": lambda x, dtype: simple_ans_decode(x, dtype),
246+ "source_file": SOURCE_FILE,
243247 },
244248 {
245249 "name": "simple-ans-delta",
@@ -247,6 +251,7 @@ algorithms = [
247251 "encode": lambda x: simple_ans_delta_encode(x),
248252 "decode": lambda x, dtype: simple_ans_delta_decode(x, dtype),
249253 "tags": ["delta_encoding"],
254+ "source_file": SOURCE_FILE,
250255 },
251256 {
252257 "name": "simple-ans-markov",
@@ -254,5 +259,6 @@ algorithms = [
254259 "encode": lambda x: simple_ans_markov_encode(x),
255260 "decode": lambda x, dtype: simple_ans_markov_decode(x, dtype),
256261 "tags": ["markov_prediction"],
262+ "source_file": SOURCE_FILE,
257263 },
258264 ]
zia_benchmark/src/zia_benchmark/algorithms/zlib/__init__.pymodified+9−0View file
@@ -1,6 +1,9 @@
11 import numpy as np
22
33
4+SOURCE_FILE = "zlib/__init__.py"
5+
6+
47 def zlib_encode(x: np.ndarray, level: int) -> bytes:
58 import zlib
69
@@ -45,6 +48,7 @@ algorithms = [
4548 "decode": lambda x, dtype: zlib_decode(x, dtype),
4649 "description": "Zlib DEFLATE compression at level 1 (fastest).",
4750 "tags": [],
51+ "source_file": SOURCE_FILE,
4852 },
4953 {
5054 "name": "zlib-3",
@@ -53,6 +57,7 @@ algorithms = [
5357 "decode": lambda x, dtype: zlib_decode(x, dtype),
5458 "description": "Zlib DEFLATE compression at level 3.",
5559 "tags": [],
60+ "source_file": SOURCE_FILE,
5661 },
5762 {
5863 "name": "zlib-5",
@@ -61,6 +66,7 @@ algorithms = [
6166 "decode": lambda x, dtype: zlib_decode(x, dtype),
6267 "description": "Zlib DEFLATE compression at level 5 (medium).",
6368 "tags": [],
69+ "source_file": SOURCE_FILE,
6470 },
6571 {
6672 "name": "zlib-7",
@@ -69,6 +75,7 @@ algorithms = [
6975 "decode": lambda x, dtype: zlib_decode(x, dtype),
7076 "description": "Zlib DEFLATE compression at level 7.",
7177 "tags": [],
78+ "source_file": SOURCE_FILE,
7279 },
7380 {
7481 "name": "zlib-9",
@@ -77,6 +84,7 @@ algorithms = [
7784 "decode": lambda x, dtype: zlib_decode(x, dtype),
7885 "description": "Zlib DEFLATE compression at maximum level 9.",
7986 "tags": [],
87+ "source_file": SOURCE_FILE,
8088 },
8189 {
8290 "name": "zlib-9-delta",
@@ -85,5 +93,6 @@ algorithms = [
8593 "decode": lambda x, dtype: zlib_delta_decode(x, dtype),
8694 "description": "Zlib DEFLATE compression at level 9 with delta encoding.",
8795 "tags": ["delta_encoding"],
96+ "source_file": SOURCE_FILE,
8897 },
8998 ]
zia_benchmark/src/zia_benchmark/algorithms/zstd/__init__.pymodified+11−0View file
@@ -1,6 +1,9 @@
11 import numpy as np
22
33
4+SOURCE_FILE = "zstd/__init__.py"
5+
6+
47 def zstd_delta_encode(x: np.ndarray, level: int) -> bytes:
58 import zstandard as zstd
69
@@ -47,42 +50,49 @@ algorithms = [
4750 "version": "1",
4851 "encode": lambda x: zstd_encode(x, level=4),
4952 "decode": lambda x, dtype: zstd_decode(x, dtype),
53+ "source_file": SOURCE_FILE,
5054 },
5155 {
5256 "name": "zstd-7",
5357 "version": "1",
5458 "encode": lambda x: zstd_encode(x, level=7),
5559 "decode": lambda x, dtype: zstd_decode(x, dtype),
60+ "source_file": SOURCE_FILE,
5661 },
5762 {
5863 "name": "zstd-10",
5964 "version": "1",
6065 "encode": lambda x: zstd_encode(x, level=10),
6166 "decode": lambda x, dtype: zstd_decode(x, dtype),
67+ "source_file": SOURCE_FILE,
6268 },
6369 {
6470 "name": "zstd-13",
6571 "version": "1",
6672 "encode": lambda x: zstd_encode(x, level=13),
6773 "decode": lambda x, dtype: zstd_decode(x, dtype),
74+ "source_file": SOURCE_FILE,
6875 },
6976 {
7077 "name": "zstd-16",
7178 "version": "1",
7279 "encode": lambda x: zstd_encode(x, level=16),
7380 "decode": lambda x, dtype: zstd_decode(x, dtype),
81+ "source_file": SOURCE_FILE,
7482 },
7583 {
7684 "name": "zstd-19",
7785 "version": "1",
7886 "encode": lambda x: zstd_encode(x, level=19),
7987 "decode": lambda x, dtype: zstd_decode(x, dtype),
88+ "source_file": SOURCE_FILE,
8089 },
8190 {
8291 "name": "zstd-22",
8392 "version": "1",
8493 "encode": lambda x: zstd_encode(x, level=22),
8594 "decode": lambda x, dtype: zstd_decode(x, dtype),
95+ "source_file": SOURCE_FILE,
8696 },
8797 {
8898 "name": "zstd-22-delta",
@@ -90,5 +100,6 @@ algorithms = [
90100 "encode": lambda x: zstd_delta_encode(x, level=22),
91101 "decode": lambda x, dtype: zstd_delta_decode(x, dtype),
92102 "tags": ["delta_encoding"],
103+ "source_file": SOURCE_FILE,
93104 },
94105 ]
zia_benchmark/src/zia_benchmark/datasets/bernoulli/__init__.pymodified+8−0View file
@@ -1,6 +1,9 @@
11 import numpy as np
22
33
4+SOURCE_FILE = "bernoulli/__init__.py"
5+
6+
47 def create_bernoulli(*, n_samples: int, p: float, seed: int) -> np.ndarray:
58 rng = np.random.default_rng(seed)
69 x = rng.binomial(1, p, n_samples).astype(np.uint8)
@@ -14,6 +17,7 @@ datasets = [
1417 "create": lambda: create_bernoulli(n_samples=1_000_000, p=0.1, seed=0),
1518 "description": "Binary sequence with 10% probability of ones.",
1619 "tags": ["binary"],
20+ "source_file": SOURCE_FILE,
1721 },
1822 {
1923 "name": "bernoulli-0.2",
@@ -21,6 +25,7 @@ datasets = [
2125 "create": lambda: create_bernoulli(n_samples=1_000_000, p=0.2, seed=0),
2226 "description": "Binary sequence with 20% probability of ones.",
2327 "tags": ["binary"],
28+ "source_file": SOURCE_FILE,
2429 },
2530 {
2631 "name": "bernoulli-0.3",
@@ -28,6 +33,7 @@ datasets = [
2833 "create": lambda: create_bernoulli(n_samples=1_000_000, p=0.3, seed=0),
2934 "description": "Binary sequence with 30% probability of ones.",
3035 "tags": ["binary"],
36+ "source_file": SOURCE_FILE,
3137 },
3238 {
3339 "name": "bernoulli-0.4",
@@ -35,6 +41,7 @@ datasets = [
3541 "create": lambda: create_bernoulli(n_samples=1_000_000, p=0.4, seed=0),
3642 "description": "Binary sequence with 40% probability of ones.",
3743 "tags": ["binary"],
44+ "source_file": SOURCE_FILE,
3845 },
3946 {
4047 "name": "bernoulli-0.5",
@@ -42,5 +49,6 @@ datasets = [
4249 "create": lambda: create_bernoulli(n_samples=1_000_000, p=0.5, seed=0),
4350 "description": "Binary sequence with 50% probability of ones and 50% probability of zeros.",
4451 "tags": ["binary"],
52+ "source_file": SOURCE_FILE,
4553 },
4654 ]
zia_benchmark/src/zia_benchmark/datasets/gaussian/__init__.pymodified+8−0View file
@@ -1,6 +1,9 @@
11 import numpy as np
22
33
4+SOURCE_FILE = "gaussian/__init__.py"
5+
6+
47 def create_gaussian(*, n_samples: int, stddev: float, seed: int) -> np.ndarray:
58 rng = np.random.default_rng(seed)
69 x = np.round(rng.normal(0, stddev, n_samples)).astype(np.int16)
@@ -14,6 +17,7 @@ datasets = [
1417 "create": lambda: create_gaussian(n_samples=1_000_000, stddev=1, seed=0),
1518 "description": "Rounded Gaussian integers with σ=1.",
1619 "tags": [],
20+ "source_file": SOURCE_FILE,
1721 },
1822 {
1923 "name": "gaussian-2",
@@ -21,6 +25,7 @@ datasets = [
2125 "create": lambda: create_gaussian(n_samples=1_000_000, stddev=2, seed=0),
2226 "description": "Rounded Gaussian integers with σ=2.",
2327 "tags": [],
28+ "source_file": SOURCE_FILE,
2429 },
2530 {
2631 "name": "gaussian-3",
@@ -28,6 +33,7 @@ datasets = [
2833 "create": lambda: create_gaussian(n_samples=1_000_000, stddev=3, seed=0),
2934 "description": "Rounded Gaussian integers with σ=3.",
3035 "tags": [],
36+ "source_file": SOURCE_FILE,
3137 },
3238 {
3339 "name": "gaussian-5",
@@ -35,6 +41,7 @@ datasets = [
3541 "create": lambda: create_gaussian(n_samples=1_000_000, stddev=5, seed=0),
3642 "description": "Rounded Gaussian integers with σ=5.",
3743 "tags": [],
44+ "source_file": SOURCE_FILE,
3845 },
3946 {
4047 "name": "gaussian-8",
@@ -42,5 +49,6 @@ datasets = [
4249 "create": lambda: create_gaussian(n_samples=1_000_000, stddev=8, seed=0),
4350 "description": "Rounded Gaussian integers with σ=8.",
4451 "tags": [],
52+ "source_file": SOURCE_FILE,
4553 },
4654 ]
zia_benchmark/src/zia_benchmark/datasets/real/__init__.pymodified+9−0View file
@@ -5,6 +5,9 @@ from ..._filters import bandpass_filter
55 from ..._analysis import estimate_noise_level
66
77
8+SOURCE_FILE = "real/__init__.py"
9+
10+
811 def _load_real_000876(
912 *, num_samples: int, num_channels: int, start_channel: int
1013 ) -> np.ndarray:
@@ -110,6 +113,7 @@ datasets = [
110113 num_samples=500_000, num_channels=1, start_channel=45
111114 ).flatten(),
112115 "tags": ["continuous", "neurophysiology"],
116+ "source_file": SOURCE_FILE,
113117 },
114118 {
115119 "name": "real-000409-ch101",
@@ -119,6 +123,7 @@ datasets = [
119123 num_samples=500_000, num_channels=1, start_channel=101
120124 ).flatten(),
121125 "tags": ["continuous", "neurophysiology"],
126+ "source_file": SOURCE_FILE,
122127 },
123128 {
124129 "name": "real-001290-ch0",
@@ -128,6 +133,7 @@ datasets = [
128133 num_samples=500_000, num_channels=1, start_channel=0
129134 ).flatten(),
130135 "tags": ["continuous", "neurophysiology"],
136+ "source_file": SOURCE_FILE,
131137 },
132138 {
133139 "name": "real-000876-ch45-filtered",
@@ -139,6 +145,7 @@ datasets = [
139145 ).flatten()
140146 ),
141147 "tags": ["continuous", "neurophysiology", "filtered"],
148+ "source_file": SOURCE_FILE,
142149 },
143150 {
144151 "name": "real-000409-ch101-filtered",
@@ -150,6 +157,7 @@ datasets = [
150157 ).flatten()
151158 ),
152159 "tags": ["continuous", "neurophysiology", "filtered"],
160+ "source_file": SOURCE_FILE,
153161 },
154162 {
155163 "name": "real-001290-ch0-filtered",
@@ -161,5 +169,6 @@ datasets = [
161169 ).flatten()
162170 ),
163171 "tags": ["continuous", "neurophysiology", "filtered"],
172+ "source_file": SOURCE_FILE,
164173 },
165174 ]
zia_benchmark/src/zia_benchmark/run_benchmarks.pymodified+22−16View file
@@ -10,6 +10,10 @@ from ._memobin import construct_memobin_url, upload_to_memobin, download_from_me
1010
1111
1212 system_version = "v4"
13+GITHUB_ALGORITHMS_PREFIX = "https://github.com/magland/zia/blob/main/zia_benchmark/src/zia_benchmark/algorithms/"
14+GITHUB_DATASETS_PREFIX = (
15+ "https://github.com/magland/zia/blob/main/zia_benchmark/src/zia_benchmark/datasets/"
16+)
1317
1418
1519 def is_compatible(algorithm_tags: List[str], dataset_tags: List[str]) -> bool:
@@ -247,24 +251,26 @@ def run_benchmarks(
247251 # Collect algorithm and dataset information as lists
248252 algorithm_info = []
249253 for algorithm in algorithms:
250- algorithm_info.append(
251- {
252- "name": algorithm["name"],
253- "description": algorithm.get("description", ""),
254- "version": algorithm["version"],
255- "tags": algorithm.get("tags", []),
256- }
257- )
254+ info = {
255+ "name": algorithm["name"],
256+ "description": algorithm.get("description", ""),
257+ "version": algorithm["version"],
258+ "tags": algorithm.get("tags", []),
259+ }
260+ if "source_file" in algorithm:
261+ info["source_file"] = GITHUB_ALGORITHMS_PREFIX + algorithm["source_file"]
262+ algorithm_info.append(info)
258263
259264 dataset_info = []
260265 for dataset in datasets:
261- dataset_info.append(
262- {
263- "name": dataset["name"],
264- "description": dataset.get("description", ""),
265- "version": dataset["version"],
266- "tags": dataset.get("tags", []),
267- }
268- )
266+ info = {
267+ "name": dataset["name"],
268+ "description": dataset.get("description", ""),
269+ "version": dataset["version"],
270+ "tags": dataset.get("tags", []),
271+ }
272+ if "source_file" in dataset:
273+ info["source_file"] = GITHUB_DATASETS_PREFIX + dataset["source_file"]
274+ dataset_info.append(info)
269275
270276 return {"results": results, "algorithms": algorithm_info, "datasets": dataset_info}