Skip to content

Commit 8caa722

Browse files
committed
DEPR: move NumericIndex._convert_tolerance to Index
1 parent 1c17d94 commit 8caa722

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

pandas/core/indexes/base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3761,6 +3761,17 @@ def _convert_tolerance(self, tolerance, target: np.ndarray | Index) -> np.ndarra
37613761
tolerance = np.asarray(tolerance)
37623762
if target.size != tolerance.size and tolerance.size > 1:
37633763
raise ValueError("list-like tolerance size must match target index size")
3764+
elif is_numeric_dtype(self) and not np.issubdtype(tolerance.dtype, np.number):
3765+
if tolerance.ndim > 0:
3766+
raise ValueError(
3767+
f"tolerance argument for {type(self).__name__} must contain "
3768+
"numeric elements if it is list type"
3769+
)
3770+
3771+
raise ValueError(
3772+
f"tolerance argument for {type(self).__name__} must be numeric "
3773+
f"if it is a scalar: {repr(tolerance)}"
3774+
)
37643775
return tolerance
37653776

37663777
@final

pandas/core/indexes/numeric.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -224,22 +224,6 @@ def _maybe_cast_slice_bound(self, label, side: str):
224224

225225
# ----------------------------------------------------------------
226226

227-
def _convert_tolerance(self, tolerance, target):
228-
tolerance = super()._convert_tolerance(tolerance, target)
229-
230-
if not np.issubdtype(tolerance.dtype, np.number):
231-
if tolerance.ndim > 0:
232-
raise ValueError(
233-
f"tolerance argument for {type(self).__name__} must contain "
234-
"numeric elements if it is list type"
235-
)
236-
237-
raise ValueError(
238-
f"tolerance argument for {type(self).__name__} must be numeric "
239-
f"if it is a scalar: {repr(tolerance)}"
240-
)
241-
return tolerance
242-
243227
@classmethod
244228
def _assert_safe_casting(cls, data: np.ndarray, subarr: np.ndarray) -> None:
245229
"""

0 commit comments

Comments
 (0)