ENH add types in quickflat and vertex mappers - #670
Draft
kroq-gar78 wants to merge 3 commits into
Draft
Conversation
kroq-gar78
force-pushed
the
types/05-dataset-core
branch
2 times, most recently
from
August 20, 2026 20:05
a813aad to
b7c0186
Compare
mvdoc
force-pushed
the
types/05-dataset-core
branch
2 times, most recently
from
August 20, 2026 20:55
b56ca41 to
d6a8710
Compare
Contributor
Author
|
I'm splitting up the quickflat and Mapper annotations into separate PRs. |
kroq-gar78
force-pushed
the
types/05-dataset-core
branch
2 times, most recently
from
August 20, 2026 21:43
f2c8170 to
5afd170
Compare
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
force-pushed
the
types/06-07-mapper-quickflat-core
branch
from
August 20, 2026 21:47
5da4e89 to
7e22e02
Compare
kroq-gar78
force-pushed
the
types/05-dataset-core
branch
from
August 20, 2026 21:47
5afd170 to
375ac57
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NOTE: this is WIP. It has broken mapper changes.
This PR adds type support for the non-SVG functions in
cortex.quickflatand standardizes the Mapper API.It also improves test coverage for the many arguments of
quickflat.make_figure.Stack created with GitHub Stacks CLI • Give Feedback 💬