Skip to content

Clear the last Python-backend xfails - #659

Merged
suraj-ranganath merged 2 commits into
developfrom
cursor/clear-last-python-backend-xfails-29e9
Nov 19, 2026
Merged

suraj-ranganath merged 2 commits into
developfrom
cursor/clear-last-python-backend-xfails-29e9

Conversation

@suraj-ranganath

@suraj-ranganath suraj-ranganath commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

eeg_store fills a free ALLEEG slot when data is empty, including a struct element created by assigning indices 1 and 3. eeg_store.m uses isempty(ALLEEG(i).data). Python only treated {} as empty, so the datasets were appended. The library still returns a list of dataset dicts. The comparison already presents that list as a struct row, and the stored result has no empty slot.

gethelpvar still returns an empty Python string for an unknown name. gethelpvar.m assigns '' inside the description cell, not an empty cell. The comparison adapter presents that string as the harness shape of '', a length-0 char vector.

importevent and pop_importdata do not resolve a variable name. importevent.m lines 199 and 228 call evalin('caller') when the event argument is a character name and no file of that name exists, and pop_importdata documents data as a base-workspace name. EEGPrep has no caller workspace. The reference test passes the same arrays on the Python path and checks latencies 1 and 50. The difference is in the migration guide.

pop_editeventfield leaves eventdescription unchanged when the named field is absent. pop_editeventfield.m assigns the cell only when strmatch finds the field. A real field description stays a Python list of strings. The comparison presents that list as the 1-by-N cell of char that eeg_checkset.m builds, so the first cell is the new comment. It is not reshaped into a character column of the whole field. The description slot is updated once per field, not once per event.

std_selectdesign.m does not call size on cluster fields such as allinds. The ported test did. EEGPrep's package version 0.5.0 was read as an EEGLAB release at most 13, so the test also ran the old cluster-membership check that current EEGLAB skips because eeg_getversion returns dev. The smoke loop accepts a list or a struct array. The membership check runs only for EEGLAB releases 9 through 13.

The Python-backend xfail registry is empty. Local unit tests: 3226 passed, 161 skipped, 3 failed on missing LIMO files in the suite checkout, pamica not installed. Python-backend lane (-m "parity and not slow and not gui"): 623 passed, 107 skipped. MATLAB is not installed here, so the MATLAB reference suite was not run.

Part of #430

Open in Web Open in Cursor 

eeg_store fills a slot whose data is empty. Missing gethelpvar text and
eventdescription cells are shaped only at the MATLAB comparison boundary.
importevent does not eval a caller workspace name. std_selectdesign keeps
list-valued cluster indices, and the ported design test no longer treats
the package version as EEGLAB <= 13.

Part of #430

Co-authored-by: Suraj Ranganath <[email protected]>

@claude claude Bot 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.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@claude

claude Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @suraj-ranganath's task in 1m 44s —— View job


Code review

  • Overall assessment: The PR needs one small change. Each cleared xfail now has a fix in the library or the comparison harness, and the deviations are documented. The eeg_store empty-slot rule matches eeg_store.m, where isempty(ALLEEG(i).data) sits inside a try/catch. The pop_editeventfield *info guard matches the strmatch branch of pop_editeventfield.m, which only warns when the field is missing.
  • Highest-risk area: the per-event loop in pop_editeventfield._apply_options.
  • Merge recommendation: needs changes

Blocking

None.

Important

  • pop_editeventfield.py L247-L251: the field-assignment loop is now quadratic in the number of events. _ensure_description_slot(..., event_field_names(events, include_urevent=True), ...) moved inside for event_index, item in zip(indices, values). event_field_names scans every event, so setting one field on all events costs O(n²). Typical continuous recordings have thousands of events. Fix: move the call back after the loop under if indices: and set description_edited = True there. Details are in the inline comment.

Nits

  • test_std_selectdesign_keeps_list_valued_cluster_indices cannot catch a real regression. std_selectdesign never reads or writes allinds/setinds, and the original AttributeError came from the harness calling .size on lists. AGENTS.md §Testing says to add only tests that would catch a real bug. Consider dropping it.

Test gaps

None.

EEGLAB parity notes

  • _legacy_membership_check puts the Python lane on the same path as the pinned MATLAB lane: EEGLAB dev makes str2num('de') <= 13 false, so the membership block is skipped. As a result, neither lane asserts cluster membership any more; the test is now a smoke test. This is acceptable for parity, but nothing now covers cluster corruption after std_selectdesign.
  • The importevent/pop_importdata workspace-name deviation is listed in the migration guide table. That matches the AGENTS.md rule that runtime code must not depend on a caller workspace.

Checked the following against eeg_store.m and pop_editeventfield.m from upstream EEGLAB:

  • correctness of the changed code
  • the eeg_store and pop_editeventfield behavior
  • the gethelpvar and eventdescription comparison adapters
  • the std_selectdesign harness changes
  • docs and changelog sync
  • AGENTS.md compliance

I did not run any tests or MATLAB here. The local vendored EEGLAB checkout was not present.

Comment on lines 247 to +251
for event_index, item in zip(indices, values):
events[event_index][key_text] = _field_value(key_text, item, srate=srate, timeunit=timeunit)
_update_matching_urevent(output, events[event_index], key_text)
_ensure_description_slot(eventdescription, event_field_names(events, include_urevent=True), key_text)
_ensure_description_slot(eventdescription, event_field_names(events, include_urevent=True), key_text)
description_edited = True

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.

Important (performance regression). _ensure_description_slot(...) moved from after this loop to inside it. It now calls event_field_names(events, include_urevent=True) once per event, and that function scans every event (_event_utils.py L32-L41). Setting one field on all events is now O(n_events²). On a continuous recording with a few thousand events, pop_editeventfield(EEG, 'type', ...) runs millions of dict iterations where it used to run one scan.

values = value_sequence(values, len(indices))
for event_index, item in zip(indices, values):
events[event_index][key_text] = _field_value(key_text, item, srate=srate, timeunit=timeunit)
_update_matching_urevent(output, events[event_index], key_text)
_ensure_description_slot(eventdescription, event_field_names(events, include_urevent=True), key_text)
description_edited = True

Suggested fix: keep the slot update outside the loop. Mark the description as edited only when an event was assigned:

        for event_index, item in zip(indices, values):
            events[event_index][key_text] = _field_value(key_text, item, srate=srate, timeunit=timeunit)
            _update_matching_urevent(output, events[event_index], key_text)
        if indices:
            _ensure_description_slot(eventdescription, event_field_names(events, include_urevent=True), key_text)
            description_edited = True

)


def test_std_selectdesign_keeps_list_valued_cluster_indices():

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.

Nit (AGENTS.md §Testing: "Only add a test that would catch a real bug"). std_selectdesign never reads or writes allinds/setinds. It sets currentdesign and calls clear_study_data_fields:

study = ensure_study(STUDY)
designs = _design_list(study.get("design"))
index = int(designind)
if index < 1 or index > len(designs) or not designs[index - 1].get("name"):
raise ValueError("Cannot select an empty STUDY.design")
study["currentdesign"] = index
study = clear_study_data_fields(study)
return study

The removed xfail was an AttributeError in the test harness, which called .size on lists. It was not a library defect, and the _flat/_count change to the reference test already covers it. This test cannot catch the regression this PR fixes, so consider dropping it.

Scanning field names once per event made a full-field edit quadratic.
The list-valued cluster test did not exercise std_selectdesign.

Co-authored-by: Suraj Ranganath <[email protected]>
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