Skip to content

CLN: address TODOs #33886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions pandas/_libs/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ def array_equivalent_object(left: object[:], right: object[:]) -> bool:
except TypeError as err:
# Avoid raising TypeError on tzawareness mismatch
# TODO: This try/except can be removed if/when Timestamp
# comparisons are change dto match datetime, see GH#28507
# comparisons are changed to match datetime, see GH#28507
if "tz-naive and tz-aware" in str(err):
return False
raise
Expand Down Expand Up @@ -2346,8 +2346,6 @@ def map_infer_mask(ndarray arr, object f, const uint8_t[:] mask, bint convert=Tr

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

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

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

result[i] = val
Expand Down
8 changes: 0 additions & 8 deletions pandas/_libs/tslibs/timedeltas.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1516,10 +1516,6 @@ class Timedelta(_Timedelta):

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

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

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

Expand Down
6 changes: 1 addition & 5 deletions pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -1522,13 +1522,9 @@ def __rsub__(self, other):
# TODO: Can we simplify/generalize these cases at all?
raise TypeError(f"cannot subtract {type(self).__name__} from {other.dtype}")
elif is_timedelta64_dtype(self.dtype):
if lib.is_integer(other) or is_integer_dtype(other):
# need to subtract before negating, since that flips freq
# -self flips self.freq, messing up results
return -(self - other)

return (-self) + other

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

def __iadd__(self, other):
Expand Down
1 change: 0 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -8989,7 +8989,6 @@ def _AXIS_NAMES(self) -> Dict[int, str]:


def _from_nested_dict(data):
# TODO: this should be seriously cythonized
new_data = collections.defaultdict(dict)
for index, s in data.items():
for col, v in s.items():
Expand Down
1 change: 0 additions & 1 deletion pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ def index_arithmetic_method(self, other):
return Index(result)

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


Expand Down
12 changes: 8 additions & 4 deletions pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,14 @@ def intersection(self, other, sort=False):
if self.equals(other):
return self._get_reconciled_name_object(other)

if not is_dtype_equal(self.dtype, other.dtype):
# TODO: fastpath for if we have a different PeriodDtype
this = self.astype("O")
other = other.astype("O")
elif is_object_dtype(other.dtype):
return self.astype("O").intersection(other, sort=sort)

elif not is_dtype_equal(self.dtype, other.dtype):
# We can infer that the intersection is empty.
# assert_can_do_setop ensures that this is not just a mismatched freq
this = self[:0].astype("O")
other = other[:0].astype("O")
return this.intersection(other, sort=sort)

return self._setop(other, sort, opname="intersection")
Expand Down
1 change: 0 additions & 1 deletion pandas/core/internals/concat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# TODO: Needs a better name; too many modules are already called "concat"
from collections import defaultdict
import copy
from typing import List
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/sas/sasreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pandas.io.common import stringify_path


# TODO: replace with Protocol in Python 3.8
# TODO(PY38): replace with Protocol in Python 3.8
class ReaderBase(metaclass=ABCMeta):
"""
Protocol for XportReader and SAS7BDATReader classes.
Expand Down