Drop the Dataset Statistics section when no chart actually renders - #399
Drop the Dataset Statistics section when no chart actually renders#399adityasingh2400 wants to merge 2 commits into
Conversation
The section guard counted appended parts instead of appended content. The nchans and sfreq renderers are appended unconditionally once their has_* flag is set, and they return an empty string when the entries they were handed carry no usable val. That empty append still grew parts, so len(parts) <= 1 was False and the page kept a Dataset Statistics heading above an empty cohort grid. Test the joined content instead, so a dataset with no usable subject, age, channel-count or sampling-frequency metadata collapses the section entirely. Closes eegdash#378
|
Two things about the red here, and the second one is a problem with my own PR rather than with CI. The failures are a network outage, not this change. All 21 in
The part worth acting on: my tests are not running. The job reports so the 106 lines I added are skipped in the I would rather fix that than leave a test that only ever passes locally. Before I pick an approach, which would you prefer:
Happy to implement whichever fits how you want this directory covered. |
The test job installs the package without doc dependencies, so
importorskip("sphinx") skipped this whole file and the PR had no CI
coverage. sections.py touches sphinx once, for a module logger, so a
stdlib logger stands in and the functions under test are unchanged.
|
Went with option 1 since it is the only one that needs nothing from you, and leaving the file skipped meant this PR had no coverage at all. Say the word if you would rather have option 2 or 3 and I will switch.
Verified in a venv built the way the test job builds one, One thing you may want to look at separately: The 21 |
Closes #378.
The section already had a guard meant to collapse it when there is nothing to show, but it counted appended parts instead of appended content. The channel count and sampling frequency renderers are appended unconditionally once their
has_flag is set, and_make_count_bar_chartreturns an empty string when the entries it was handed carry no usableval. That empty append still grewparts, solen(parts) <= 1was False and the page kept a Dataset Statistics heading above an empty cohort grid.Testing the joined content instead makes the section collapse for a dataset with no usable subject, age, channel count or sampling frequency metadata, which is the case in the issue. The change is one line in
_format_recording_stats_sectionplus a comment explaining why it tests content rather than length.The issue body is empty, so I traced the symptom to the code rather than working from a description. Added
tests/test_dataset_page_stats.pywith six cases, following thesection_modulefixture pattern already used bytest_dataset_page_electrodes.py. Three of them fail ondevelop, and the failure diff prints exactly the reported symptom, aDataset Statisticsheading followed by an emptyeegdash-ed-cohort-grid. The other two go the other direction, checking that a dataset with real channel counts or a real duration still renders, so the guard does not overcorrect.After the change, 11 pass, my 6 plus the 5 existing dataset_page tests. The repo's own pre-commit ruff args pass clean and
ruff format --checkreports both files already formatted.Disclosure: this change was prepared with AI assistance. I have reviewed and tested it.