Skip to content

fix(docs): sort numeric summary columns containing "varies" sentinel#1118

Open
bkowshik wants to merge 2 commits into
NeuroTechX:developfrom
bkowshik:fix/summary-table-numeric-sort
Open

fix(docs): sort numeric summary columns containing "varies" sentinel#1118
bkowshik wants to merge 2 commits into
NeuroTechX:developfrom
bkowshik:fix/summary-table-numeric-sort

Conversation

@bkowshik

@bkowshik bkowshik commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What

Fix numeric sorting on the dataset summary tables (https://moabb.neurotechx.com/docs/dataset_summary.html). Clicking Total_trials (and #Trials / class, #Runs) sorted lexicographically instead of numerically:

Screenshot before the fix, sorted by Total trials (last) column.

image
before: 11000, 1114, 11496, 1200, 13440, ...
after:  480, 1114, 1200, 1400, ... 250000

Why

The .sortable paradigm tables are initialized with a single shared DataTable() call and no per-column config, so DataTables auto-detects each column's type. Auto-detection is all-or-nothing: a single non-numeric cell downgrades the whole column to string sorting. Several numeric columns carry the varies sentinel for datasets whose trial count isn't fixed, which poisoned detection.

Prior art: #705 fixed this class of bug at the data layer (stripping unit suffixes, e.g. 512Hz -> 512). That approach is fragile — it only holds while every cell stays clean — and #868 reintroduced the bug with varies rows. Unlike a unit suffix, varies carries real meaning and can't just be stripped, so the fix belongs in the sort engine.

Fix

Register a custom DataTables column type num-varies (docs/source/_static/js/sortable-numeric.js) that treats a column as numeric when every cell is a number or a known sentinel (varies, blank, n/a, ...), ordering sentinel rows as -Infinity so they sink to the bottom. Displayed text is unchanged — varies still reads as varies. Wired in via conf.py. No CSV data changed.

Screenshot after the fix, sorted by Total trials (last) column.

image

Verification

Sort-key logic verified against the real summary_imagery.csv values; docs build green. Final check: click Total_trials in the rendered page.

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