Repository navigation
Clear Python-backend xfails at the root and the MATLAB transport - #658
Conversation
Read struct and cell inputs in the dataset, event, channel, and STUDY helpers, and present MATLAB shapes only when the EEGLAB test harness compares outputs. Document the matchchans, hungarian, and rmart differences and drop the xfails those fixes cover. Co-authored-by: Suraj Ranganath <[email protected]>
There was a problem hiding this comment.
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 finished @suraj-ranganath's task in 2m 18s —— View job Code review
BlockingNone. Important
Nits
Test gaps
EEGLAB parity notes
Notes on this run
|
| recorded = info.get("comps") | ||
| if ( | ||
| recorded is None | ||
| or (isinstance(recorded, np.ndarray) and recorded.size == 0) | ||
| or (isinstance(recorded, (list, tuple)) and not recorded) | ||
| ): | ||
| selected = [] | ||
| else: | ||
| selected = list(recorded) |
There was a problem hiding this comment.
Important — a MATLAB-shaped comps row is not flattened. list(recorded) on a (1, N) array returns one element: the whole row. int(comp) on line 59 then raises TypeError for N > 1. A 0-d array fails earlier, at list(). sync_datasetinfo keeps user or loaded comps unchanged (
eegprep/src/eegprep/functions/studyfunc/_study_utils.py
Lines 162 to 166 in b849148
comps can arrive in this shape. This may also explain the remaining test_reference_pop_clust xfail. is_matlab_empty already covers all three empty cases checked here.
After applying the suggestion, also add is_matlab_empty to the imports from eegprep.functions.miscfunc.matlab_inputs:
| recorded = info.get("comps") | |
| if ( | |
| recorded is None | |
| or (isinstance(recorded, np.ndarray) and recorded.size == 0) | |
| or (isinstance(recorded, (list, tuple)) and not recorded) | |
| ): | |
| selected = [] | |
| else: | |
| selected = list(recorded) | |
| recorded = info.get("comps") | |
| selected = [] if is_matlab_empty(recorded) else np.asarray(recorded, dtype=float).reshape(-1).astype(int).tolist() |
There was a problem hiding this comment.
🤖 Flattened a (1, N) comps row with is_matlab_empty and reshape(-1), and added test_ensure_parent_cluster_flattens_a_matlab_component_row. test_reference_pop_clust now passes.
| def _present(value: Any) -> bool: | ||
| if value is None: | ||
| return False | ||
| if isinstance(value, np.ndarray): | ||
| return value.size > 0 | ||
| if isinstance(value, (list, tuple, str)): | ||
| return len(value) > 0 | ||
| return True |
There was a problem hiding this comment.
Nit — this duplicates an existing helper. _present(x) is not is_matlab_empty(x) from miscfunc/matlab_inputs.py. That module is already imported here, and pop_chancenter uses it in this same PR. AGENTS.md lists "Parallel implementations of existing helpers" as a failure pattern. Delete _present, import is_matlab_empty, and use if not is_matlab_empty(refloc): at line 67.
There was a problem hiding this comment.
🤖 Removed _present. reref uses is_matlab_empty, and a structured refloc is appended as location records. The result stays the flattened channels-by-frames matrix, matching reref.m. test_reference_reref now passes.
A (1, N) comps row is one component list, and an empty refloc uses the shared MATLAB empty check. Co-authored-by: Suraj Ranganath <[email protected]>
Datasets, BDF headers, and location lists stay Python objects inside call_python. Compared outputs are shaped only at the assertion. pop_rmbase history, reref refloc, rejtrend windows, finputcheck cells, and structured pop_saveset fields follow the EEGLAB functions. Co-authored-by: Suraj Ranganath <[email protected]>
Co-authored-by: Suraj Ranganath <[email protected]>
Keep MATLAB shaping on compared outputs so datasets, BDF headers, and location lists stay Python objects for the next call. pop_rmbase history, reref refloc records, rejtrend window length, finputcheck character cells, and structured pop_saveset fields now follow the EEGLAB functions. Six Python-backend xfails remain.
Part of #430