Skip to content

ENH add types in quickflat and vertex mappers - #670

Draft
kroq-gar78 wants to merge 3 commits into
types/05-dataset-corefrom
types/06-07-mapper-quickflat-core
Draft

ENH add types in quickflat and vertex mappers#670
kroq-gar78 wants to merge 3 commits into
types/05-dataset-corefrom
types/06-07-mapper-quickflat-core

Conversation

@kroq-gar78

@kroq-gar78 kroq-gar78 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

NOTE: this is WIP. It has broken mapper changes.


This PR adds type support for the non-SVG functions in cortex.quickflat and standardizes the Mapper API.

It also improves test coverage for the many arguments of quickflat.make_figure.


Stack created with GitHub Stacks CLIGive Feedback 💬

@kroq-gar78
kroq-gar78 force-pushed the types/05-dataset-core branch 2 times, most recently from a813aad to b7c0186 Compare August 20, 2026 20:05
@mvdoc
mvdoc force-pushed the types/05-dataset-core branch 2 times, most recently from b56ca41 to d6a8710 Compare August 20, 2026 20:55
@kroq-gar78

Copy link
Copy Markdown
Contributor Author

I'm splitting up the quickflat and Mapper annotations into separate PRs.

@kroq-gar78
kroq-gar78 force-pushed the types/05-dataset-core branch 2 times, most recently from f2c8170 to 5afd170 Compare August 20, 2026 21:43
Types add_curvature, add_data, add_hatch, add_colorbar, add_colorbar_2d,
add_connected_vertices, and all of view.py/utils.py's non-SVG helpers.
add_rois, add_sulci, add_custom, add_cutout, and _convert_svg_kwargs are
deliberately left untyped here — they call into cortex.svgoverlay directly
and land with that module in PR 8 instead (see PR_SPLIT_PLAN.md).

Built by diffing this worktree's pre-typing composite.py/utils.py against
types-easy's final versions and keeping only the non-SVG-function hunks,
rather than replaying the ~14 original historical commits individually —
several of those commits interleave SVG and non-SVG hunks in ways that
don't split cleanly commit-by-commit. test_quickflat.py's four new
ROI-specific test functions (test_roi_styling_parameters,
test_roi_list_and_sulci_list, test_combined_parameters, and the ROI/sulci
assertions inside test_display_flags) are included here rather than held
back for PR 8, since they don't block anything at runtime and splitting
test_display_flags mid-function is not worthwhile.

Verified: zero diff against types-easy for composite.py (excluding the 4
SVG functions + the Sequence import, which stay untyped pending PR 8),
and zero diff for utils.py/view.py/test_quickflat.py.
Types cortex/mapper/{__init__,mapper,line,patch,point,samplers}.py.
These files are exclusively owned by PR 6 (no commit before this one in
main..types-easy touches cortex/mapper/), so checked out directly from
types-easy rather than replayed commit-by-commit.

Verified: zero diff against types-easy for all six mapper files.
… 2a3c944c)

PR 6 renames get_mapper's `type` parameter to `maptype` (mypy Wave 3,
2a3c944c: `type` shadowed the builtin `type` used on the very next line).
cortex/utils.py has four call sites still using the old `type=` keyword;
since get_mapper has **kwargs, this wasn't a clean TypeError — the old
keyword silently landed in **kwargs, get_mapper defaulted `maptype` to
"nearest" regardless of what was requested, and the leftover kwarg then
propagated down to the sampler functions where PR 6 also added a "raise
ValueError on unexpected kwargs" check, surfacing as a confusing
ValueError several frames removed from the actual cause (or, worse, no
error at all and silently the wrong mapper class if a cache file for
"nearest" already happened to exist).

Reproduced before this commit:
  get_mapper('S1', 'fullhead', type='trilinear', recache=True)
  -> ValueError: nearest sampler does not take any kwargs

This isn't otherwise in PR 6 or PR 7's file list (cortex/utils.py belongs
to PR 12), but is picked from PR 12's 2a3c944c here — just the four
`type=` -> `maptype=` call-site renames in get_cortical_mask,
get_hemi_masks, get_roi_mask, and get_roi_masks — so that PR 6+7 doesn't
leave get_mapper's real callers broken. PR 12 will still add full typing
to cortex/utils.py; this commit only touches the four call sites that
would otherwise regress.

Verified: get_cortical_mask, get_hemi_masks, and get_roi_masks all run
correctly against the S1 test subject after this fix; all 4 previously
failed or behaved incorrectly before it (get_mapper('S1', 'fullhead',
type='trilinear', recache=True) reproduces the bug directly).
@kroq-gar78
kroq-gar78 force-pushed the types/06-07-mapper-quickflat-core branch from 5da4e89 to 7e22e02 Compare August 20, 2026 21:47
@kroq-gar78
kroq-gar78 force-pushed the types/05-dataset-core branch from 5afd170 to 375ac57 Compare August 20, 2026 21:47
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