refactor: decompose _type_check_params, _convert_shapes, _set_color_source_vec#741
Merged
Merged
Conversation
…elpers (#716) Split the 372-line, CCN~164 _type_check_params into 19 module-private _check_* helpers, each validating one parameter group in place; the function is now a flat ordered sequence of calls. Behavior-preserving: the call order (hence the first-raised error for any input) and all param_dict mutations are identical. Verified by a 370-case old-vs-new differential (0 mismatches) and the full non-visual suite (510 passed). Notable: contour_px keeps two checks at their original positions (type before color, range after outline) and _check_contour_px_range re-fetches contour_px from param_dict; the interleaved cmap/palette/groups region stays one helper. Adds a direct order-preservation test (color before contour_px range).
1e2f8ab to
fbfa9b4
Compare
…#716) Hoist the stateless circle->hexagon/square/circle converters to module level and dedup the copy-pasted convex-hull enclosing-circle computation into a single _enclosing_circle helper (was duplicated across the polygon and multipolygon paths). _convert_shapes keeps only the closures that bind max_extent / the warn_shape_size flag. Behavior-preserving: verified byte-identical geometry output (old vs new) across circles/polygons/multipolygons x circle/hex/visium_hex/square.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #741 +/- ##
==========================================
+ Coverage 79.31% 79.59% +0.27%
==========================================
Files 17 17
Lines 4603 4641 +38
Branches 1030 1029 -1
==========================================
+ Hits 3651 3694 +43
+ Misses 602 598 -4
+ Partials 350 349 -1
🚀 New features to boost your workflow:
|
…ource_vec (#716) Pull the three self-contained decision blocks out of the 236-line color resolver: _resolve_color_origins (locate + df/table shadowing + multi-origin error), _fetch_color_source_vector (direct-read fast path vs whole-table join), and _resolve_color_table (which table supplies .uns colors). _set_color_source_vec drops 236->171 lines (CCN ~48->~29); the categorical-mapping and output assembly stay inline. Behavior-preserving: verified byte-identical (source_vector, color_vector, categorical) output over 160 cases (element x color-column x palette x groups x render_type); full non-visual suite green (510 passed).
2ef6a86 to
6bf751c
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.
Closes #716. Decomposes the relocated mega-functions, one commit per function for bisectability.
Commits
_type_check_params(_validate.py, 372 lines / CCN≈164) → 19 module-private_check_*helpers + a flat ordered orchestrator (CCN≈1). Behavior-preserving: call order (first-raised error) and allparam_dictmutations identical.contour_pxkeeps its split type/range checks at their original positions; the interleaved cmap/palette/groups region stays oneelement_type-aware helper. Verified: 370-case old-vs-main differential, 0 mismatches; newtest_type_check_params_preserves_validation_order._convert_shapes(_geometry.py) → hoisted the stateless circle→hex/square/circle converters to module level and deduped the copy-pasted convex-hull into one_enclosing_circle. Verified: byte-identical geometry output across circles/polygons/multipolygons × circle/hex/visium_hex/square._set_color_source_vec(_color.py, 236 lines / CCN≈48 → 171 / CCN≈29) → extracted_resolve_color_origins,_fetch_color_source_vector,_resolve_color_table(the categorical-mapping + output assembly stay inline). Verified: byte-identical(source_vector, color_vector, categorical)over 160 cases (element × color-column × palette × groups × render_type).Not done (deliberately)
_get_collection_shape— the issue listed it (CCN 39), but #699 has since shrunk it to 65 lines / CCN≈17, below the decomposition bar. Left as-is.Verification
Full non-visual suite 510 passed on each step. The two rendering-output functions (
_convert_shapes,_set_color_source_vec) are additionally locked by the differential harnesses above; final visual sign-off is CI baselines.