Skip to content

Commit 6c65328

Browse files
committed
DEPR: move NumericIndex._convert_tolerance to Index
1 parent 77afbcc commit 6c65328

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
@@ -3764,6 +3764,17 @@ def _convert_tolerance(self, tolerance, target: np.ndarray | Index) -> np.ndarra
37643764
tolerance = np.asarray(tolerance)
37653765
if target.size != tolerance.size and tolerance.size > 1:
37663766
raise ValueError("list-like tolerance size must match target index size")
3767+
elif is_numeric_dtype(self) and not np.issubdtype(tolerance.dtype, np.number):
3768+
if tolerance.ndim > 0:
3769+
raise ValueError(
3770+
f"tolerance argument for {type(self).__name__} must contain "
3771+
"numeric elements if it is list type"
3772+
)
3773+
3774+
raise ValueError(
3775+
f"tolerance argument for {type(self).__name__} must be numeric "
3776+
f"if it is a scalar: {repr(tolerance)}"
3777+
)
37673778
return tolerance
37683779

37693780
@final

pandas/core/indexes/numeric.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -251,22 +251,6 @@ def _shallow_copy(self, values, name: Hashable = lib.no_default):
251251
return Float64Index._simple_new(values, name=name)
252252
return super()._shallow_copy(values=values, name=name)
253253

254-
def _convert_tolerance(self, tolerance, target):
255-
tolerance = super()._convert_tolerance(tolerance, target)
256-
257-
if not np.issubdtype(tolerance.dtype, np.number):
258-
if tolerance.ndim > 0:
259-
raise ValueError(
260-
f"tolerance argument for {type(self).__name__} must contain "
261-
"numeric elements if it is list type"
262-
)
263-
264-
raise ValueError(
265-
f"tolerance argument for {type(self).__name__} must be numeric "
266-
f"if it is a scalar: {repr(tolerance)}"
267-
)
268-
return tolerance
269-
270254
@classmethod
271255
def _assert_safe_casting(cls, data: np.ndarray, subarr: np.ndarray) -> None:
272256
"""

0 commit comments

Comments
 (0)