Skip to content

Commit b62a3a4

Browse files
authored
CLN: address TODOs (#33886)
1 parent be58cd9 commit b62a3a4

File tree

8 files changed

+11
-26
lines changed

8 files changed

+11
-26
lines changed

pandas/_libs/lib.pyx

+1-5
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ def array_equivalent_object(left: object[:], right: object[:]) -> bool:
589589
except TypeError as err:
590590
# Avoid raising TypeError on tzawareness mismatch
591591
# TODO: This try/except can be removed if/when Timestamp
592-
# comparisons are change dto match datetime, see GH#28507
592+
# comparisons are changed to match datetime, see GH#28507
593593
if "tz-naive and tz-aware" in str(err):
594594
return False
595595
raise
@@ -2346,8 +2346,6 @@ def map_infer_mask(ndarray arr, object f, const uint8_t[:] mask, bint convert=Tr
23462346

23472347
if cnp.PyArray_IsZeroDim(val):
23482348
# unbox 0-dim arrays, GH#690
2349-
# TODO: is there a faster way to unbox?
2350-
# item_from_zerodim?
23512349
val = val.item()
23522350

23532351
result[i] = val
@@ -2388,8 +2386,6 @@ def map_infer(ndarray arr, object f, bint convert=True):
23882386

23892387
if cnp.PyArray_IsZeroDim(val):
23902388
# unbox 0-dim arrays, GH#690
2391-
# TODO: is there a faster way to unbox?
2392-
# item_from_zerodim?
23932389
val = val.item()
23942390

23952391
result[i] = val

pandas/_libs/tslibs/timedeltas.pyx

-8
Original file line numberDiff line numberDiff line change
@@ -1516,10 +1516,6 @@ class Timedelta(_Timedelta):
15161516

15171517
def __rmod__(self, other):
15181518
# Naive implementation, room for optimization
1519-
if hasattr(other, 'dtype') and other.dtype.kind == 'i':
1520-
# TODO: Remove this check with backwards-compat shim
1521-
# for integer / Timedelta is removed.
1522-
raise TypeError(f'Invalid dtype {other.dtype} for __mod__')
15231519
return self.__rdivmod__(other)[1]
15241520

15251521
def __divmod__(self, other):
@@ -1529,10 +1525,6 @@ class Timedelta(_Timedelta):
15291525

15301526
def __rdivmod__(self, other):
15311527
# Naive implementation, room for optimization
1532-
if hasattr(other, 'dtype') and other.dtype.kind == 'i':
1533-
# TODO: Remove this check with backwards-compat shim
1534-
# for integer / Timedelta is removed.
1535-
raise TypeError(f'Invalid dtype {other.dtype} for __mod__')
15361528
div = other // self
15371529
return div, other - div * self
15381530

pandas/core/arrays/datetimelike.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -1511,13 +1511,9 @@ def __rsub__(self, other):
15111511
# TODO: Can we simplify/generalize these cases at all?
15121512
raise TypeError(f"cannot subtract {type(self).__name__} from {other.dtype}")
15131513
elif is_timedelta64_dtype(self.dtype):
1514-
if lib.is_integer(other) or is_integer_dtype(other):
1515-
# need to subtract before negating, since that flips freq
1516-
# -self flips self.freq, messing up results
1517-
return -(self - other)
1518-
15191514
return (-self) + other
15201515

1516+
# We get here with e.g. datetime objects
15211517
return -(self - other)
15221518

15231519
def __iadd__(self, other):

pandas/core/frame.py

-1
Original file line numberDiff line numberDiff line change
@@ -8989,7 +8989,6 @@ def _AXIS_NAMES(self) -> Dict[int, str]:
89898989

89908990

89918991
def _from_nested_dict(data):
8992-
# TODO: this should be seriously cythonized
89938992
new_data = collections.defaultdict(dict)
89948993
for index, s in data.items():
89958994
for col, v in s.items():

pandas/core/indexes/base.py

-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ def index_arithmetic_method(self, other):
151151
return Index(result)
152152

153153
name = f"__{op.__name__}__"
154-
# TODO: docstring?
155154
return set_function_name(index_arithmetic_method, name, cls)
156155

157156

pandas/core/indexes/period.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -668,10 +668,14 @@ def intersection(self, other, sort=False):
668668
if self.equals(other):
669669
return self._get_reconciled_name_object(other)
670670

671-
if not is_dtype_equal(self.dtype, other.dtype):
672-
# TODO: fastpath for if we have a different PeriodDtype
673-
this = self.astype("O")
674-
other = other.astype("O")
671+
elif is_object_dtype(other.dtype):
672+
return self.astype("O").intersection(other, sort=sort)
673+
674+
elif not is_dtype_equal(self.dtype, other.dtype):
675+
# We can infer that the intersection is empty.
676+
# assert_can_do_setop ensures that this is not just a mismatched freq
677+
this = self[:0].astype("O")
678+
other = other[:0].astype("O")
675679
return this.intersection(other, sort=sort)
676680

677681
return self._setop(other, sort, opname="intersection")

pandas/core/internals/concat.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# TODO: Needs a better name; too many modules are already called "concat"
21
from collections import defaultdict
32
import copy
43
from typing import List

pandas/io/sas/sasreader.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pandas.io.common import stringify_path
88

99

10-
# TODO: replace with Protocol in Python 3.8
10+
# TODO(PY38): replace with Protocol in Python 3.8
1111
class ReaderBase(metaclass=ABCMeta):
1212
"""
1313
Protocol for XportReader and SAS7BDATReader classes.

0 commit comments

Comments
 (0)