Skip to content

[eegprep-lean] Fix edge cases in reading a store's electrode positions - #627

Merged
neuromechanist merged 5 commits into
developfrom
agent/20261117-u1b-reader-edge-cases
Nov 17, 2026
Merged

neuromechanist merged 5 commits into
developfrom
agent/20261117-u1b-reader-edge-cases

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Follow-up to #626, from review of the code that consumes the electrode-positions reader. Three edge cases of a store root's electrode_positions now follow NEMAR's locations digest, which is defined on binary64 values.

A coordinate that is an integer too large for a float (400 digits, or any integer from 2^1024 minus 2^970) raised OverflowError and failed the whole read; it is now a channel without a position. The root is parsed with parse_int=float, as JSON.parse reads it. That also removes the 4300-digit limit, which raised ValueError before any entry existed, so an entry-level catch alone could not cover it. A small OverflowError guard stays for from_attributes called with Python integers.

Every zero is now +0.0 whatever its sign or spelling, as the digest hashes it. Before, -0.0 was kept and the integer -0 was not, and the sign of a zero set the sign of Y and theta (180 or -180). The BIDS import is unchanged and keeps -0.0 for a minus-signed zero in a float column of an electrodes.tsv (an all-integer column reads -0 as +0.0), so for such a file Y and theta can differ in sign between the two routes. The 13-pair route-equality test still passes, and a new one checks that a store's -0.0 gives what the import gives for 0.0.

A non-object electrode_positions still raises, because the digest refuses it too, but as ElectrodePositionsNotAnObject (an IndexError_), so a caller records the reason by type. A test now pins an attributes of [] or null as no attributes.

Each case has tests and a mutation check. Lean suites in the root, zarr, plot, both and combined environments pass (368, 353, 327, 373 and 414).

@claude claude Bot left a comment

Copy link
Copy Markdown

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 17, 2026 •

Copy link
Copy Markdown

Claude finished @neuromechanist's task in 48s —— View job


Code review

  • Overall assessment: Looks good. I checked that _position (float(axis) + 0.0, the OverflowError guard, the finiteness check after conversion), json.loads(..., parse_int=float) and the new ElectrodePositionsNotAnObject subclass do what the PR description says.
  • Highest-risk area: parse_int=float applies to the whole root zarr.json. Only electrode_positions is numeric among the attributes from_attributes reads. The other four (electrode_coordinate_system, _units, _positions_source, _positions_file) are strings read through _text, so nothing else changes.
  • Merge recommendation: Safe to merge.

Blocking

None.

Important

None.

Nits

None.

Test gaps

None. Each new case has a test:

  • integers just below and just above the overflow threshold (2**1024 - 2**970), and 400-digit integers of either sign
  • -0 and -0.0 spelled in JSON text and read over real HTTP
  • a byte-level comparison of chanlocs for stores that differ only in a signed zero, in the EEGLAB frame and in CapTrak (RAS) turned to ALS
  • the refusal type for lists, strings, numbers and True/False, plus null as no positions

EEGLAB parity notes

None. This is reader-side code in eegprep-lean and has no EEGLAB counterpart. The difference from pop_load_frombids for a -0.0 in a float column of electrodes.tsv is intentional. Both changelogs record it, and the new route-equality test pins what the store route returns.

Checked for correctness bugs, EEGLAB parity, data structure compatibility, changed-behavior tests, and CLAUDE.md/AGENTS.md compliance. I could not re-run the lean test suites here because running commands was not permitted in this job; the counts in the PR body come from the author's run.

@neuromechanist
neuromechanist merged commit 2736f99 into develop Nov 17, 2026
17 checks passed
@neuromechanist
neuromechanist deleted the agent/20261117-u1b-reader-edge-cases branch November 17, 2026 14:15
neuromechanist added a commit to nemarOrg/nemar-process that referenced this pull request Nov 17, 2026
The eegprep-lean pin moves to the merge commit of sccn/eegprep pull request 627 on develop. The reader now reads a store whose integer coordinate is past binary64 (a position-less channel, digested like every other store), records the named refusal ElectrodePositionsNotAnObject for a non-object positions attribute, and reads every zero as +0.0 so the reader hands what the digest names. All thirteen locations vectors, the huge-integer one included, now reproduce through the reader's own parser. Tests and docs follow the new behavior; no version moves because no image was published at the pre-release version; tests and CI green.
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