Adapt numerical base transformers to narwhals-returning check_X - #1022
Merged
solegalli merged 1 commit intoAug 30, 2026
Merged
Conversation
Since #1019, check_X / check_X_y return a narwhals DataFrame instead of the native frame. BaseNumericalTransformer._fit_setup / ._check_transform_input_and_state and FitFromDictMixin._fit_from_dict rebind `X = check_X(X)` and then pass that frame to find_numerical_variables, check_numerical_variables, _check_contains_na and _check_contains_inf. Those helpers branch on nwd.is_pandas_dataframe() internally. Handed a narwhals frame they take the non-pandas path and emit a UserWarning per call ("You passed a narwhals.dataframe.DataFrame to is_pandas_dataframe") - a single LogTransformer.fit_transform on pandas raised 5 such warnings - while the pandas fast paths are silently skipped. check_X is pure validation (no copy, no reshape), so the fix is to stop rebinding X and keep passing the helpers the native input, exactly as before #1019. The transformation classes themselves need no changes (they are already backend-agnostic: nw.from_native(X) on whatever the base returns). This also restores the pre-#1019 baseline for the other consumers of these bases: test_scaling 19/0 (was 14 failing), test_discretisation 5 failing (was 23). No test changes; mypy and flake8 clean. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
solegalli
force-pushed
the
narwhals-numerical-base-adapt-check-x
branch
from
August 30, 2026 14:54
e8bf2eb to
7beb0a0
Compare
solegalli
added a commit
that referenced
this pull request
Aug 30, 2026
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.
update classes to narwhals return from check_x