Skip to content

Commit cc9a112

Browse files
tqa236pmhatre1
authored andcommitted
CLN: Remove some unused code (pandas-dev#57839)
* CLN: Remove some unused code * Review
1 parent 9aa319b commit cc9a112

File tree

6 files changed

+6
-72
lines changed

6 files changed

+6
-72
lines changed

pandas/_config/config.py

-6
Original file line numberDiff line numberDiff line change
@@ -583,12 +583,6 @@ def _get_root(key: str) -> tuple[dict[str, Any], str]:
583583
return cursor, path[-1]
584584

585585

586-
def _is_deprecated(key: str) -> bool:
587-
"""Returns True if the given option has been deprecated"""
588-
key = key.lower()
589-
return key in _deprecated_options
590-
591-
592586
def _get_deprecated_option(key: str):
593587
"""
594588
Retrieves the metadata for a deprecated option, if `key` is deprecated.

pandas/core/computation/ops.py

-6
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,6 @@ def _not_in(x, y):
320320
)
321321
_arith_ops_dict = dict(zip(ARITH_OPS_SYMS, _arith_ops_funcs))
322322

323-
SPECIAL_CASE_ARITH_OPS_SYMS = ("**", "//", "%")
324-
_special_case_arith_ops_funcs = (operator.pow, operator.floordiv, operator.mod)
325-
_special_case_arith_ops_dict = dict(
326-
zip(SPECIAL_CASE_ARITH_OPS_SYMS, _special_case_arith_ops_funcs)
327-
)
328-
329323
_binary_ops_dict = {}
330324

331325
for d in (_cmp_ops_dict, _bool_ops_dict, _arith_ops_dict):

pandas/core/missing.py

-53
Original file line numberDiff line numberDiff line change
@@ -801,59 +801,6 @@ def _cubicspline_interpolate(
801801
return P(x)
802802

803803

804-
def _interpolate_with_limit_area(
805-
values: np.ndarray,
806-
method: Literal["pad", "backfill"],
807-
limit: int | None,
808-
limit_area: Literal["inside", "outside"],
809-
) -> None:
810-
"""
811-
Apply interpolation and limit_area logic to values along a to-be-specified axis.
812-
813-
Parameters
814-
----------
815-
values: np.ndarray
816-
Input array.
817-
method: str
818-
Interpolation method. Could be "bfill" or "pad"
819-
limit: int, optional
820-
Index limit on interpolation.
821-
limit_area: {'inside', 'outside'}
822-
Limit area for interpolation.
823-
824-
Notes
825-
-----
826-
Modifies values in-place.
827-
"""
828-
829-
invalid = isna(values)
830-
is_valid = ~invalid
831-
832-
if not invalid.all():
833-
first = find_valid_index(how="first", is_valid=is_valid)
834-
if first is None:
835-
first = 0
836-
last = find_valid_index(how="last", is_valid=is_valid)
837-
if last is None:
838-
last = len(values)
839-
840-
pad_or_backfill_inplace(
841-
values,
842-
method=method,
843-
limit=limit,
844-
limit_area=limit_area,
845-
)
846-
847-
if limit_area == "inside":
848-
invalid[first : last + 1] = False
849-
elif limit_area == "outside":
850-
invalid[:first] = invalid[last + 1 :] = False
851-
else:
852-
raise ValueError("limit_area should be 'inside' or 'outside'")
853-
854-
values[invalid] = np.nan
855-
856-
857804
def pad_or_backfill_inplace(
858805
values: np.ndarray,
859806
method: Literal["pad", "backfill"] = "pad",

pandas/plotting/_misc.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,7 @@ class _Options(dict):
637637
_ALIASES = {"x_compat": "xaxis.compat"}
638638
_DEFAULT_KEYS = ["xaxis.compat"]
639639

640-
def __init__(self, deprecated: bool = False) -> None:
641-
self._deprecated = deprecated
640+
def __init__(self) -> None:
642641
super().__setitem__("xaxis.compat", False)
643642

644643
def __getitem__(self, key):

pandas/tests/computation/test_eval.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
)
4949
from pandas.core.computation.ops import (
5050
ARITH_OPS_SYMS,
51-
SPECIAL_CASE_ARITH_OPS_SYMS,
5251
_binary_math_ops,
5352
_binary_ops_dict,
5453
_unary_math_ops,
@@ -266,7 +265,7 @@ def test_chained_cmp_op(self, cmp1, cmp2, lhs, midhs, rhs, engine, parser):
266265
tm.assert_almost_equal(result, expected)
267266

268267
@pytest.mark.parametrize(
269-
"arith1", sorted(set(ARITH_OPS_SYMS).difference(SPECIAL_CASE_ARITH_OPS_SYMS))
268+
"arith1", sorted(set(ARITH_OPS_SYMS).difference({"**", "//", "%"}))
270269
)
271270
def test_binary_arith_ops(self, arith1, lhs, rhs, engine, parser):
272271
ex = f"lhs {arith1} rhs"

pandas/tests/config/test_config.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,11 @@ def test_case_insensitive(self):
123123
msg = r"No such keys\(s\): 'no_such_option'"
124124
with pytest.raises(OptionError, match=msg):
125125
cf.get_option("no_such_option")
126-
cf.deprecate_option("KanBan")
127126

128-
assert cf._is_deprecated("kAnBaN")
127+
cf.deprecate_option("KanBan")
128+
msg = "'kanban' is deprecated, please refrain from using it."
129+
with pytest.raises(FutureWarning, match=msg):
130+
cf.get_option("kAnBaN")
129131

130132
def test_get_option(self):
131133
cf.register_option("a", 1, "doc")
@@ -268,7 +270,6 @@ def test_deprecate_option(self):
268270
# we can deprecate non-existent options
269271
cf.deprecate_option("foo")
270272

271-
assert cf._is_deprecated("foo")
272273
with tm.assert_produces_warning(FutureWarning, match="deprecated"):
273274
with pytest.raises(KeyError, match="No such keys.s.: 'foo'"):
274275
cf.get_option("foo")

0 commit comments

Comments
 (0)