Skip to content

FIX repr of windows datasets built with lazy_metadata=True (NotImplementedError / KeyError) - #1529

Merged
bruAristimunha merged 1 commit into
braindecode:masterfrom
bruAristimunha:bd2deep/lazy-metadata-repr
Nov 2, 2026
Merged

bruAristimunha merged 1 commit into
braindecode:masterfrom
bruAristimunha:bd2deep/lazy-metadata-repr

Conversation

@bruAristimunha

@bruAristimunha bruAristimunha commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Printing a windows dataset built with lazy_metadata=True raises:

ds = create_fixed_length_windows(concat_ds, window_size_samples=200, window_stride_samples=100,
                                 on_last_window="drop", lazy_metadata=True)
print(ds)   # NotImplementedError: Row indexing only supports either a single integer or a null slice

BaseConcatDataset.__repr__ and _repr_html_ (#934) summarize the windows' metadata with column indexing (md["i_stop_in_trial"]), which _LazyDataFrame does not support. The concat summary (_concat_metadata_summary) now skips lazy metadata, as the per-dataset _metadata_summary already did. The per-dataset repr also failed: _window_info read the first crop row with first[2], but a lazy row is a pd.Series labelled by column, so it raised KeyError. It now reads the row by position. For such datasets the repr shows no window sizes or target counts. This affects 1.8.x too. It was found by running examples/applied_examples/tutorial_create_fixed_window_length.py, which prints such a dataset; the gallery does not execute that file.

  • New test test_repr_of_windows_with_lazy_metadata.
  • whats_new entry under Bug fixes.

Verified in a Voyager Job: pre-commit run --files exits 0, and pytest test_dataset.py test_windowers.py -k "repr or lazy" passes (33 passed).

BaseConcatDataset.__repr__/_repr_html_ summarize the windows' metadata
with column indexing, which _LazyDataFrame does not support, so printing
create_fixed_length_windows(..., lazy_metadata=True) raised
NotImplementedError (found by running tutorial_create_fixed_window_length).
The per-dataset summary already skipped lazy metadata; the concat summary
now does the same.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Mixed eager and lazy window datasets produce misleading aggregate summaries because lazy metadata is skipped without suppressing or labeling the resulting partial statistics.

1 open issue
What changed in this PR

This PR fixes text and HTML representations of window datasets created with lazy_metadata=True, addressing failures in the dataset summaries introduced by #934.

Changes:

  • Skip unsupported column access when summarizing lazy metadata.
  • Convert the first crop row to an array for positional access.
  • Add a regression test and a bug-fix changelog entry.
File Description
test/​unit_tests/​datasets/​test_dataset.py Tests concat text/HTML and child text representations with lazy metadata.
docs/​whats_new.rst Documents the representation fixes.
braindecode/​datasets/​base.py Handles lazy metadata in concat summaries and crop-row access.

Review effort: Balanced

Comment on lines +153 to +156
if not isinstance(md, pd.DataFrame):
# lazy metadata (lazy_metadata=True) only supports row access, as
# in _metadata_summary: no window sizes or target counts from it
continue
@bruAristimunha
bruAristimunha force-pushed the bd2deep/lazy-metadata-repr branch from cd08202 to daab46a Compare November 2, 2026 17:18
Copilot AI balanced review requested due to automatic review settings November 2, 2026 17:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Mixed eager/lazy datasets report eager-only window and target statistics as whole-dataset totals, producing misleading aggregate summaries.

1 open issue

Review effort: Balanced

@bruAristimunha
bruAristimunha merged commit 789eebe into braindecode:master Nov 2, 2026
7 checks passed
@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.36%. Comparing base (535e058) to head (daab46a).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1529      +/-   ##
==========================================
+ Coverage   91.34%   91.36%   +0.02%     
==========================================
  Files         170      170              
  Lines       22105    22107       +2     
==========================================
+ Hits        20192    20199       +7     
+ Misses       1913     1908       -5     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants