-
Notifications
You must be signed in to change notification settings - Fork 0
Persist normalization stats to data/normalization_stats.json #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| *.egg-info/ | ||
| .env | ||
| /exported | ||
| .github/ | ||
| /model_checkpoints | ||
| __pycache__/ | ||
| *.py[cod] | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |||||||||
| from scipy.signal import resample, butter, lfilter | ||||||||||
| import numpy as np | ||||||||||
| import os | ||||||||||
| import json | ||||||||||
| import tensorflow as tf | ||||||||||
| from collections import Counter | ||||||||||
| from sklearn.model_selection import train_test_split | ||||||||||
|
|
@@ -157,6 +158,23 @@ def compute_statistics(dataset): | |||||||||
| mean, std = total_sum / total_count, np.sqrt((total_sum_sq / total_count) - (total_sum / total_count) ** 2) | ||||||||||
| return mean, std | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def upsert_normalization_stats(stats_path, updates): | ||||||||||
| """Merge normalization stats into JSON at stats_path, creating file if needed.""" | ||||||||||
| os.makedirs(os.path.dirname(os.fspath(stats_path)), exist_ok=True) | ||||||||||
|
||||||||||
| os.makedirs(os.path.dirname(os.fspath(stats_path)), exist_ok=True) | |
| dir_name = os.path.dirname(os.fspath(stats_path)) | |
| if dir_name: | |
| os.makedirs(dir_name, exist_ok=True) |
Copilot
AI
Mar 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue #15 requires deterministic JSON output, but json.dump(existing, ..., indent=2) does not enforce a stable key order; the serialized ordering will depend on insertion/update history. Add sort_keys=True (and keep indentation) so repeated runs produce a deterministic file layout.
| json.dump(existing, f, indent=2) | |
| json.dump(existing, f, indent=2, sort_keys=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section mentions the output path and which scripts write which keys, but it’s still missing two items called out in issue #15/PR description: (1) an example JSON snippet showing the expected shape, and (2) a brief note on overwrite/upsert behavior (reruns overwrite only the keys they compute). Adding both here would make the README sufficient for downstream consumers without needing to read the PR description.