Skip to content

Commit 2ef4853

Browse files
nithish-74L G Nithish Reddyjeremiedbb
authored
MNT Add caller name to scale input validation (scikit-learn#31816)
Co-authored-by: L G Nithish Reddy <your-reddylnithish@gmail.com> Co-authored-by: Jérémie du Boisberranger <jeremie@probabl.ai>
1 parent a619e79 commit 2ef4853

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

sklearn/preprocessing/_data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ def scale(X, *, axis=0, with_mean=True, with_std=True, copy=True):
229229
estimator="the scale function",
230230
dtype=FLOAT_DTYPES,
231231
ensure_all_finite="allow-nan",
232+
input_name="X",
232233
)
233234
if sparse.issparse(X):
234235
if with_mean:

sklearn/preprocessing/tests/test_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,10 +1042,10 @@ def test_scale_sparse_with_mean_raise_exception(sparse_container):
10421042

10431043

10441044
def test_scale_input_finiteness_validation():
1045-
# Check if non finite inputs raise ValueError
1045+
# Check if non-finite inputs raise ValueError
10461046
X = [[np.inf, 5, 6, 7, 8]]
10471047
with pytest.raises(
1048-
ValueError, match="Input contains infinity or a value too large"
1048+
ValueError, match=r"Input X contains infinity or a value too large for dtype"
10491049
):
10501050
scale(X)
10511051

0 commit comments

Comments
 (0)