Repository navigation
Conversation
Only PLETransformer checked that y has one row per sample. The B/M/I splines failed with a raw IndexError, and the natural and cubic regression splines and the feature maps with a NumPy broadcast error inside the location selector. The unsupervised natural and cubic regression splines also aligned an unused y with the finite rows and failed when X had a missing value. A shared check_target_length helper in pretab.core.validation raises PretabDataError naming the estimator and both lengths. The spline base, the spline mixins and the feature-map base call it before target-aware placement, and the selectors as a safety net. The mixins drop y when no selector reads it. Fixes #175
This branch has not been deployed
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.
Fixes #175.
A target-aware fit with a
yof the wrong length raised a raw NumPyIndexError(B/M/I splines) or broadcastValueError(natural/cubic-regression splines and the feature maps). Only PLE raised a typed error. The unsupervised natural and cubic-regression splines also failed on a wrong-lengthywhenXhad a missing value, although they ignorey.Root cause
ywas aligned withX's rows, except in PLE.BaseSplineTransformer.fitslicedywith a mask ofX's length, andBaseLocationSelector.selectbroadcast a mismatchedy._finite_columnalignedywith the finite rows even when no selector would read it.Fix
check_target_length(n_samples, y, estimator)inpretab/core/validation.pyraisesPretabDataError:<Estimator>: X and y must have same length. Got 100 and 60; ....Xwithyfor target-aware placement:BaseSplineTransformer.fit(B/M/I);SplineBasisMixin._place_spanning_knots/_place_interior_knots(natural and cubic-regression splines);BaseFunctionalExpansion.fit(RBF, ReLU, sigmoid, tanh);BaseLocationSelector.select, as a safety net for direct selector use.y = Nonewhen there is no selector, so unsupervised fits ignoreyas documented.PLE keeps its existing check and message.
Behaviour changes
yraisesPretabDataErrorfor every target-aware representation. Before, it raised anIndexErrororValueError.ywhenXhas missing values. Their output is unchanged, sinceywas never used.yare unchanged. The golden regression baselines pass without regeneration.Documentation
check_target_lengthdocstring, and a NumPy-style docstring forBaseSplineTransformer.fit, which had a one-line summary only, with the newRaisesentry.docs/core_concepts/target_awareness.md: ayof another length raisesPretabDataErrorfor every target-aware fit.Tests
tests/expansion/spline/test_spline_expansions.py::test_target_aware_fit_rejects_a_target_of_another_length(nine families × shorter and longery): fails onmain, passes here.tests/expansion/spline/test_spline_expansions.py::test_unsupervised_fit_ignores_the_length_of_y(nine families): the natural and cubic-regression cases fail onmain; the others are guards that pass on both.tests/core/test_location_selectors.py::test_selector_rejects_a_target_of_another_length: fails onmain, passes here.Reproduction
The script from #175 on this branch:
Checks
just test: 4704 passed, 59 skipped, 7 xfailed; coverage 95.73% (gate 90%).scripts/quickstart.pypasses.just docs: strict build succeeds.just check: all pre-commit and pre-push hooks pass (file hygiene, ruff format, ruff lint, prettier, pyright with 0 errors).pretab.core.validation.pretab.core.selectorsand the expansion modules import it from core, following the documented dependency direction.Merge notes
main.pretab/core/validation.py(reject_non_finite, in another part of the module), and fix(splines): choose thin-plate landmarks from complete rows #152 and fix(splines): continue the M-spline boundary pieces when extrapolating #162 edit other spline files. Git merges this branch cleanly with every open per-issue branch (fix(binning): reject edges the soft encoding cannot use #150 to fix(output): keep numeric dtypes next to passed-through categories #174).