refactor: convert experimental parameters to TypedDicts (1/4) - #1279
refactor: convert experimental parameters to TypedDicts (1/4)#1279selmanozleyen wants to merge 8 commits into
Conversation
cd1fa5b to
36451d4
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1279 +/- ##
==========================================
+ Coverage 78.75% 79.25% +0.50%
==========================================
Files 63 64 +1
Lines 9370 9357 -13
Branches 1558 1528 -30
==========================================
+ Hits 7379 7416 +37
+ Misses 1421 1392 -29
+ Partials 570 549 -21
🚀 New features to boost your workflow:
|
d1001aa to
affe9e0
Compare
Brings in scverse#1279 (params as TypedDicts with their defaults declared on the key), scverse#1280 (StainFit and its methods), the enum-to-Literal pass, and the API page restructuring, so the align work sits on the shape those settle rather than carrying its own copy of it. Conflicts resolved toward the stack for everything it owns: the params, the defaults machinery, the enum conversion and the docs templates all come from there, and the three copies this branch had made of them are dropped. The alignment surface is what this branch adds on top -- the `stalign_align_*` entry points, the fit classes they return, and `rasterize_points`/`sample_volume`. `Stalign*Params` move into `squidpy.types` with the rest. Re-exporting them from `_align._stalign` deadlocked at import: `types` would have imported the implementation package whose `__init__` imports `types`. They are declared there now, like every other params class, and `_stalign` reads them back. `_matches` in the params test grew a tolerant union arm. It walks a key's declared type to check the default against it, and `npt.ArrayLike` unions in protocols that are not `runtime_checkable`, so `isinstance` raised before reaching the `None` arm that actually matched.
5ef501c to
5146abb
Compare
5146abb to
0586b10
Compare
The module holds the public parameter bags, and later the result tuples that go with them. Those are not experimental, so `squidpy.types` is where the whole set belongs -- and introducing it under `experimental` only to move it a PR later is churn a reviewer should not have to follow. Its docs section moves with it: it was rendering as `### Types` nested under `## Experimental`, so the page filed a top-level module as an experimental one. Imported by `squidpy/__init__` rather than left to arrive as a side effect: it resolved before only because `experimental.im._detect_tissue` imports it eagerly, so `sq.types` would have vanished the moment `experimental` became lazy, while `import squidpy.types` kept working.
The ``**background_detection_params`` entry landed before ``inplace``, and ``border_margin_px`` ahead of the two parameters it follows, so the rendered parameter list disagreed with the signature above it.
``any_corner`` is an internal helper in ``_detect_tissue``: not exported, not importable, and nothing a reader of the public params class can look up. State the fallback instead of pointing at it.
``validate_qc_params``, ``validate_reinhard_params`` and ``validate_stitch_params`` are internal helpers: not exported, not importable, nothing a reader of the public params class can look up. The surrounding sentences said what every params class already says by being one, so they go with them.
|
Nice, I like the plan and consistency. What I don’t get is the distinction between spelling kwargs out in the function and having them defined in a TypedDict: are they always shared? Is there a rule about what goes where? |
|
|
hi @timtreis, so these are what I noticed on the kwargs bags. I think it's useful to rethink them:
|
Hi,
I want to bring a clear separation to the kwargs madness we have here.
StainReferenceorAlignmentResultwe use frozen data classes . Even if they are given as input later to other functions since we don't expect the user to type those it doesn't make sense to unpack. Based on this instinct I also have a follow up PR to stack on refactor: add StainReference transform methods (2/4) #1280NamedTuple(like current SpatialNeighboursResults)(about the nesting of functions by groups I am open to discussion, but it's really unreadable if we have a flat
tl.*. I would also argue that we want to deprecate.imanyway. So we might as well put everything insideexperimental.im.*undertlto make it less confusing if we will do this grouping in the docs.Intended end result after one more pr in this stack:
Fits
Functions
Results
Params