Skip to content

CLN/TST: address/annotate TODOs #44154

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 2 commits into from
Oct 24, 2021
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
8 changes: 4 additions & 4 deletions pandas/_libs/algos.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ def rank_1d(

N = len(values)
if labels is not None:
# TODO Cython 3.0: cast won't be necessary (#2992)
# TODO(cython3): cast won't be necessary (#2992)
assert <Py_ssize_t>len(labels) == N
out = np.empty(N)
grp_sizes = np.ones(N, dtype=np.int64)
Expand Down Expand Up @@ -1086,7 +1086,7 @@ cdef void rank_sorted_1d(
# array that we sorted previously, which gives us the location of
# that sorted value for retrieval back from the original
# values / masked_vals arrays
# TODO: de-duplicate once cython supports conditional nogil
# TODO(cython3): de-duplicate once cython supports conditional nogil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably good to reference in #34213 that these TODO styles can be addressed (or vice versa)?

if iu_64_floating_obj_t is object:
with gil:
for i in range(N):
Expand Down Expand Up @@ -1413,7 +1413,7 @@ ctypedef fused out_t:
@cython.boundscheck(False)
@cython.wraparound(False)
def diff_2d(
ndarray[diff_t, ndim=2] arr, # TODO(cython 3) update to "const diff_t[:, :] arr"
ndarray[diff_t, ndim=2] arr, # TODO(cython3) update to "const diff_t[:, :] arr"
ndarray[out_t, ndim=2] out,
Py_ssize_t periods,
int axis,
Expand All @@ -1422,7 +1422,7 @@ def diff_2d(
cdef:
Py_ssize_t i, j, sx, sy, start, stop
bint f_contig = arr.flags.f_contiguous
# bint f_contig = arr.is_f_contig() # TODO(cython 3)
# bint f_contig = arr.is_f_contig() # TODO(cython3)
diff_t left, right

# Disable for unsupported dtype combinations,
Expand Down
10 changes: 5 additions & 5 deletions pandas/_libs/groupby.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ def group_last(iu_64_floating_obj_t[:, ::1] out,
ndarray[int64_t, ndim=2] nobs
bint runtime_error = False

# TODO(cython 3.0):
# TODO(cython3):
# Instead of `labels.shape[0]` use `len(labels)`
if not len(values) == labels.shape[0]:
raise AssertionError("len(index) != len(labels)")
Expand All @@ -978,7 +978,7 @@ def group_last(iu_64_floating_obj_t[:, ::1] out,
N, K = (<object>values).shape

if iu_64_floating_obj_t is object:
# TODO: De-duplicate once conditional-nogil is available
# TODO(cython3): De-duplicate once conditional-nogil is available
for i in range(N):
lab = labels[i]
if lab < 0:
Expand Down Expand Up @@ -1057,7 +1057,7 @@ def group_nth(iu_64_floating_obj_t[:, ::1] out,
ndarray[int64_t, ndim=2] nobs
bint runtime_error = False

# TODO(cython 3.0):
# TODO(cython3):
# Instead of `labels.shape[0]` use `len(labels)`
if not len(values) == labels.shape[0]:
raise AssertionError("len(index) != len(labels)")
Expand All @@ -1072,7 +1072,7 @@ def group_nth(iu_64_floating_obj_t[:, ::1] out,
N, K = (<object>values).shape

if iu_64_floating_obj_t is object:
# TODO: De-duplicate once conditional-nogil is available
# TODO(cython3): De-duplicate once conditional-nogil is available
for i in range(N):
lab = labels[i]
if lab < 0:
Expand Down Expand Up @@ -1255,7 +1255,7 @@ cdef group_min_max(iu_64_floating_t[:, ::1] out,
bint uses_mask = mask is not None
bint isna_entry

# TODO(cython 3.0):
# TODO(cython3):
# Instead of `labels.shape[0]` use `len(labels)`
if not len(values) == labels.shape[0]:
raise AssertionError("len(index) != len(labels)")
Expand Down
2 changes: 0 additions & 2 deletions pandas/_libs/tslibs/nattype.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ cdef class _NaT(datetime):

elif util.is_integer_object(other):
# For Period compat
# TODO: the integer behavior is deprecated, remove it
return c_NaT

elif util.is_array(other):
Expand Down Expand Up @@ -201,7 +200,6 @@ cdef class _NaT(datetime):

elif util.is_integer_object(other):
# For Period compat
# TODO: the integer behavior is deprecated, remove it
return c_NaT

elif util.is_array(other):
Expand Down
6 changes: 3 additions & 3 deletions pandas/_libs/tslibs/parsing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ def try_parse_date_and_time(
object[:] result

n = len(dates)
# TODO(cython 3.0): Use len instead of `shape[0]`
# TODO(cython3): Use len instead of `shape[0]`
if times.shape[0] != n:
raise ValueError('Length of dates and times must be equal')
result = np.empty(n, dtype='O')
Expand Down Expand Up @@ -709,7 +709,7 @@ def try_parse_year_month_day(
object[:] result

n = len(years)
# TODO(cython 3.0): Use len instead of `shape[0]`
# TODO(cython3): Use len instead of `shape[0]`
if months.shape[0] != n or days.shape[0] != n:
raise ValueError('Length of years/months/days must all be equal')
result = np.empty(n, dtype='O')
Expand All @@ -735,7 +735,7 @@ def try_parse_datetime_components(object[:] years,
double micros

n = len(years)
# TODO(cython 3.0): Use len instead of `shape[0]`
# TODO(cython3): Use len instead of `shape[0]`
if (
months.shape[0] != n
or days.shape[0] != n
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/window/rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def __init__(
self.window = window
self.min_periods = min_periods
self.center = center
# TODO: Change this back to self.win_type once deprecation is enforced
# TODO(2.0): Change this back to self.win_type once deprecation is enforced
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, good to attach this TODO style to an issue.

self._win_type = win_type
self.axis = obj._get_axis_number(axis) if axis is not None else None
self.method = method
Expand Down Expand Up @@ -262,7 +262,7 @@ def _gotitem(self, key, ndim, subset=None):
# we need to make a shallow copy of ourselves
# with the same groupby
with warnings.catch_warnings():
# TODO: Remove once win_type deprecation is enforced
# TODO(2.0): Remove once win_type deprecation is enforced
warnings.filterwarnings("ignore", "win_type", FutureWarning)
kwargs = {attr: getattr(self, attr) for attr in self._attributes}

Expand Down
4 changes: 2 additions & 2 deletions pandas/io/parsers/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def read_csv(
# Error Handling
error_bad_lines=None,
warn_bad_lines=None,
# TODO (2.0): set on_bad_lines to "error".
# TODO(2.0): set on_bad_lines to "error".
# See _refine_defaults_read comment for why we do this.
on_bad_lines=None,
# Internal
Expand Down Expand Up @@ -704,7 +704,7 @@ def read_table(
# Error Handling
error_bad_lines=None,
warn_bad_lines=None,
# TODO (2.0): set on_bad_lines to "error".
# TODO(2.0): set on_bad_lines to "error".
# See _refine_defaults_read comment for why we do this.
on_bad_lines=None,
# Internal
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ def convert_delta_safe(base, deltas, unit) -> Series:
deltas = to_timedelta(deltas, unit=unit)
return base + deltas

# TODO: If/when pandas supports more than datetime64[ns], this should be
# improved to use correct range, e.g. datetime[Y] for yearly
# TODO(non-nano): If/when pandas supports more than datetime64[ns], this
# should be improved to use correct range, e.g. datetime[Y] for yearly
bad_locs = np.isnan(dates)
has_bad_values = False
if bad_locs.any():
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/arrays/sparse/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,7 @@ def test_from_coo(self):
row = [0, 3, 1, 0]
col = [0, 3, 1, 2]
data = [4, 5, 7, 9]
# TODO: Remove dtype when scipy is fixed
# TODO(scipy#13585): Remove dtype when scipy is fixed
# https://github.com/scipy/scipy/issues/13585
sp_array = scipy.sparse.coo_matrix((data, (row, col)), dtype="int")
result = pd.Series.sparse.from_coo(sp_array)
Expand Down
14 changes: 6 additions & 8 deletions pandas/tests/frame/methods/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,14 @@ def test_join_index_more(float_frame):

def test_join_index_series(float_frame):
df = float_frame.copy()
s = df.pop(float_frame.columns[-1])
joined = df.join(s)
ser = df.pop(float_frame.columns[-1])
joined = df.join(ser)

# TODO should this check_names ?
tm.assert_frame_equal(joined, float_frame, check_names=False)
tm.assert_frame_equal(joined, float_frame)

s.name = None
ser.name = None
with pytest.raises(ValueError, match="must have a name"):
df.join(s)
df.join(ser)


def test_join_overlap(float_frame):
Expand Down Expand Up @@ -241,8 +240,7 @@ def test_join(self, multiindex_dataframe_random_data):

assert not np.isnan(joined.values).all()

# TODO what should join do with names ?
tm.assert_frame_equal(joined, expected, check_names=False)
tm.assert_frame_equal(joined, expected)

def test_join_segfault(self):
# GH#1532
Expand Down
13 changes: 6 additions & 7 deletions pandas/tests/frame/methods/test_reset_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,32 +144,31 @@ def test_reset_index(self, float_frame):
df = float_frame.reset_index().set_index(["index", "A", "B"])
rs = df.reset_index(["A", "B"])

# TODO should reset_index check_names ?
tm.assert_frame_equal(rs, float_frame, check_names=False)
tm.assert_frame_equal(rs, float_frame)

rs = df.reset_index(["index", "A", "B"])
tm.assert_frame_equal(rs, float_frame.reset_index(), check_names=False)
tm.assert_frame_equal(rs, float_frame.reset_index())

rs = df.reset_index(["index", "A", "B"])
tm.assert_frame_equal(rs, float_frame.reset_index(), check_names=False)
tm.assert_frame_equal(rs, float_frame.reset_index())

rs = df.reset_index("A")
xp = float_frame.reset_index().set_index(["index", "B"])
tm.assert_frame_equal(rs, xp, check_names=False)
tm.assert_frame_equal(rs, xp)

# test resetting in place
df = float_frame.copy()
reset = float_frame.reset_index()
return_value = df.reset_index(inplace=True)
assert return_value is None
tm.assert_frame_equal(df, reset, check_names=False)
tm.assert_frame_equal(df, reset)

df = float_frame.reset_index().set_index(["index", "A", "B"])
rs = df.reset_index("A", drop=True)
xp = float_frame.copy()
del xp["A"]
xp = xp.set_index(["B"], append=True)
tm.assert_frame_equal(rs, xp, check_names=False)
tm.assert_frame_equal(rs, xp)

def test_reset_index_name(self):
df = DataFrame(
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2528,7 +2528,7 @@ def check_views():
else:
# TODO: we can call check_views if we stop consolidating
# in setitem_with_indexer
# FIXME: enable after GH#35417
# FIXME(GH#35417): enable after GH#35417
# assert b[0] == 0
assert df.iloc[0, 2] == 0

Expand Down
5 changes: 1 addition & 4 deletions pandas/tests/groupby/test_allowlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import numpy as np
import pytest

import pandas.util._test_decorators as td

from pandas import (
DataFrame,
Index,
Expand Down Expand Up @@ -359,8 +357,7 @@ def test_groupby_function_rename(mframe):
"cummax",
"cummin",
"cumprod",
# TODO(ArrayManager) quantile
pytest.param("describe", marks=td.skip_array_manager_not_yet_implemented),
"describe",
"rank",
"quantile",
"diff",
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class TestGetValue:
"index", ["string", "int", "datetime", "timedelta"], indirect=True
)
def test_get_value(self, index):
# TODO: Remove function? GH#19728
# TODO(2.0): can remove once get_value deprecation is enforced GH#19728
values = np.random.randn(100)
value = index[67]

Expand Down
4 changes: 1 addition & 3 deletions pandas/tests/io/test_feather.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ def test_basic(self):
)
df["periods"] = pd.period_range("2013", freq="M", periods=3)
df["timedeltas"] = pd.timedelta_range("1 day", periods=3)
# TODO temporary disable due to regression in pyarrow 0.17.1
# https://github.com/pandas-dev/pandas/issues/34255
# df["intervals"] = pd.interval_range(0, 3, 3)
df["intervals"] = pd.interval_range(0, 3, 3)

assert df.dttz.dtype.tz.zone == "US/Eastern"
self.check_round_trip(df)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -2042,7 +2042,7 @@ def test_to_sql_with_negative_npinf(self, input, request):
# GH 36465
# The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error
# for pymysql version >= 0.10
# TODO: remove this version check after GH 36465 is fixed
# TODO(GH#36465): remove this version check after GH 36465 is fixed
import pymysql

if pymysql.VERSION[0:3] >= (0, 10, 0) and "infe0" in df.columns:
Expand Down