Skip to content

test: use synthetic data instead of downloading a real dataset in sampler tests (#545)#1035

Open
YihengLi-1 wants to merge 2 commits into
braindecode:masterfrom
YihengLi-1:speed-up-tests-synthetic-data-545
Open

test: use synthetic data instead of downloading a real dataset in sampler tests (#545)#1035
YihengLi-1 wants to merge 2 commits into
braindecode:masterfrom
YihengLi-1:speed-up-tests-synthetic-data-545

Conversation

@YihengLi-1
Copy link
Copy Markdown

Summary

Partially addresses #545. The sampler unit tests (test/unit_tests/samplers/test_samplers.py) downloaded the real BNCI2014_001 MOABB dataset (subject 4) in their windows_ds and target_windows_ds fixtures. These tests only depend on the dataset structure — the number of recordings, the number of windows, and the subject/session/run/target metadata columns — not on real EEG signals, so the download is unnecessary.

This replaces the two fixtures' data source with small synthetic data built from the existing braindecode.util.create_mne_dummy_raw helper (the util pointed to in the issue). The windowing calls and all test logic are left unchanged.

Why this is safe

The synthetic data reproduces the structure the samplers rely on:

  • 3 recordings with distinct subject/session/run, so RecordingSampler groups them into the expected number of recordings;
  • recordings long enough (52 s) that the fixed-length windows span the tau_pos/tau_neg range used by RelativePositioningSampler;
  • 48 trials per recording across 2 alternating classes, so BalancedSequenceSampler has enough consecutive windows and at least two target classes (this covers the n_windows=40 parametrization).

Result

  • All 19 tests in the file pass (12 non-distributed + 7 mp.spawn/gloo distributed).
  • The data-loading cost is gone, and the tests no longer require network access or moabb. For example, test_recording_sampler went from ~11.5 s (real download) to ~3.0 s (synthetic; the remainder is just import overhead).

Scope: only test/unit_tests/samplers/test_samplers.py. The other files listed in #545 can follow in separate PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant