Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Standardize X as inverse_transform input parameter #28756

Merged
merged 21 commits into from Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion sklearn/cluster/tests/test_feature_agglomeration.py
Expand Up @@ -70,7 +70,7 @@ def test_inverse_transform_Xt_deprecation():
with pytest.raises(TypeError, match="Missing required positional argument"):
jeremiedbb marked this conversation as resolved.
Show resolved Hide resolved
est.inverse_transform()

with pytest.raises(ValueError, match="Cannot use both X and Xt. Use X only."):
with pytest.raises(TypeError, match="Cannot use both X and Xt. Use X only."):
wd60622 marked this conversation as resolved.
Show resolved Hide resolved
est.inverse_transform(X=X, Xt=X)

with warnings.catch_warnings(record=True):
Expand Down
2 changes: 1 addition & 1 deletion sklearn/decomposition/tests/test_nmf.py
Expand Up @@ -949,7 +949,7 @@ def test_NMF_inverse_transform_Xt_deprecation(Estimator):
with pytest.raises(TypeError, match="Missing required positional argument"):
jeremiedbb marked this conversation as resolved.
Show resolved Hide resolved
est.inverse_transform()

with pytest.raises(ValueError, match="Cannot use both X and Xt. Use X only"):
with pytest.raises(TypeError, match="Cannot use both X and Xt. Use X only"):
wd60622 marked this conversation as resolved.
Show resolved Hide resolved
est.inverse_transform(X=X, Xt=X)

with warnings.catch_warnings(record=True):
Expand Down
2 changes: 1 addition & 1 deletion sklearn/model_selection/tests/test_search.py
Expand Up @@ -2565,7 +2565,7 @@ def test_inverse_transform_Xt_deprecation(SearchCV):
with pytest.raises(TypeError, match="Missing required positional argument"):
search.inverse_transform()

with pytest.raises(ValueError, match="Cannot use both X and Xt. Use X only"):
with pytest.raises(TypeError, match="Cannot use both X and Xt. Use X only"):
wd60622 marked this conversation as resolved.
Show resolved Hide resolved
search.inverse_transform(X=X2, Xt=X2)

with warnings.catch_warnings(record=True):
Expand Down
2 changes: 1 addition & 1 deletion sklearn/preprocessing/tests/test_discretization.py
Expand Up @@ -489,7 +489,7 @@ def test_KBD_inverse_transform_Xt_deprecation():
with pytest.raises(TypeError, match="Missing required positional argument"):
kbd.inverse_transform()

with pytest.raises(ValueError, match="Cannot use both X and Xt. Use X only"):
with pytest.raises(TypeError, match="Cannot use both X and Xt. Use X only"):
wd60622 marked this conversation as resolved.
Show resolved Hide resolved
kbd.inverse_transform(X=X, Xt=X)

with warnings.catch_warnings(record=True):
Expand Down
2 changes: 1 addition & 1 deletion sklearn/tests/test_pipeline.py
Expand Up @@ -1802,7 +1802,7 @@ def test_pipeline_inverse_transform_Xt_deprecation():
with pytest.raises(TypeError, match="Missing required positional argument"):
pipe.inverse_transform()

with pytest.raises(ValueError, match="Cannot use both X and Xt. Use X only"):
with pytest.raises(TypeError, match="Cannot use both X and Xt. Use X only"):
wd60622 marked this conversation as resolved.
Show resolved Hide resolved
pipe.inverse_transform(X=X, Xt=X)

with warnings.catch_warnings(record=True):
Expand Down
4 changes: 2 additions & 2 deletions sklearn/utils/deprecation.py
Expand Up @@ -120,10 +120,10 @@ def _is_deprecated(func):
def _deprecate_Xt_in_inverse_transform(X, Xt):
"""Helper to deprecate the `Xt` argument in favor of `X` in inverse_transform."""
if X is not None and Xt is not None:
raise ValueError("Cannot use both X and Xt. Use X only.")
raise TypeError("Cannot use both X and Xt. Use X only.")
wd60622 marked this conversation as resolved.
Show resolved Hide resolved

if X is None and Xt is None:
raise TypeError("Missing required positional argument: 'X'.")
raise TypeError("Missing required positional argument: X.")

if Xt is not None:
warnings.warn(
Expand Down