formatted code, added setup.py file to install packages

This commit is contained in:
Liyu Xiao 2025-05-16 11:31:37 -04:00
parent 66d4c47cc4
commit cdc293c7ce
4 changed files with 26 additions and 19 deletions

View File

@ -36,6 +36,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install h5py numpy
pip install -e
- name: 1. Build HDF5 Dataset
run: |

View File

@ -21,6 +21,7 @@ info_dtype = np.dtype(
]
)
def write_hdf5_file(records, output_path, dataset_name="data"):
"""
Writes a list of records to an HDF5 file.
@ -74,6 +75,7 @@ def write_hdf5_file(records, output_path, dataset_name="data"):
return output_path
def split_recording(recording_list):
"""
Splits a list of recordings into smaller chunks.

View File

@ -18,14 +18,12 @@ def split(dataset, train_frac=0.8, seed=42):
by_rec = defaultdict(list)
for i, (_, md) in enumerate(dataset):
by_rec[md['rec_id']].append(i)
by_rec[md["rec_id"]].append(i)
rec_ids = list(by_rec.keys())
random.seed(seed)
random.shuffle(rec_ids)
train_set = set()
count = 0
for rec_id in rec_ids:
@ -34,8 +32,6 @@ def split(dataset, train_frac=0.8, seed=42):
train_set.update(index)
count += len(index)
validation_set = set(range(N)) - train_set
print(f"Train set :{len(train_set)}")
@ -45,5 +41,3 @@ def split(dataset, train_frac=0.8, seed=42):
val_records = [dataset[i] for i in sorted(validation_set)]
return train_records, val_records

10
setup.py Normal file
View File

@ -0,0 +1,10 @@
from setuptools import setup, find_packages
setup(
name="modrec_workflow",
version="0.1",
packages=find_packages(), # this will pick up `utils/` (so utils/__init__.py must exist)
install_requires=[
# runtime dependencies go here (if any)
],
)