Skip to content

Commit 3df6aac

Browse files
authored
CLN/TST: address/annotate TODOs (#44154)
1 parent 514852c commit 3df6aac

File tree

14 files changed

+35
-43
lines changed

14 files changed

+35
-43
lines changed

pandas/_libs/algos.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ def rank_1d(
947947

948948
N = len(values)
949949
if labels is not None:
950-
# TODO Cython 3.0: cast won't be necessary (#2992)
950+
# TODO(cython3): cast won't be necessary (#2992)
951951
assert <Py_ssize_t>len(labels) == N
952952
out = np.empty(N)
953953
grp_sizes = np.ones(N, dtype=np.int64)
@@ -1086,7 +1086,7 @@ cdef void rank_sorted_1d(
10861086
# array that we sorted previously, which gives us the location of
10871087
# that sorted value for retrieval back from the original
10881088
# values / masked_vals arrays
1089-
# TODO: de-duplicate once cython supports conditional nogil
1089+
# TODO(cython3): de-duplicate once cython supports conditional nogil
10901090
if iu_64_floating_obj_t is object:
10911091
with gil:
10921092
for i in range(N):
@@ -1413,7 +1413,7 @@ ctypedef fused out_t:
14131413
@cython.boundscheck(False)
14141414
@cython.wraparound(False)
14151415
def diff_2d(
1416-
ndarray[diff_t, ndim=2] arr, # TODO(cython 3) update to "const diff_t[:, :] arr"
1416+
ndarray[diff_t, ndim=2] arr, # TODO(cython3) update to "const diff_t[:, :] arr"
14171417
ndarray[out_t, ndim=2] out,
14181418
Py_ssize_t periods,
14191419
int axis,
@@ -1422,7 +1422,7 @@ def diff_2d(
14221422
cdef:
14231423
Py_ssize_t i, j, sx, sy, start, stop
14241424
bint f_contig = arr.flags.f_contiguous
1425-
# bint f_contig = arr.is_f_contig() # TODO(cython 3)
1425+
# bint f_contig = arr.is_f_contig() # TODO(cython3)
14261426
diff_t left, right
14271427

14281428
# Disable for unsupported dtype combinations,

pandas/_libs/groupby.pyx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ def group_last(iu_64_floating_obj_t[:, ::1] out,
963963
ndarray[int64_t, ndim=2] nobs
964964
bint runtime_error = False
965965

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

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

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

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

1258-
# TODO(cython 3.0):
1258+
# TODO(cython3):
12591259
# Instead of `labels.shape[0]` use `len(labels)`
12601260
if not len(values) == labels.shape[0]:
12611261
raise AssertionError("len(index) != len(labels)")

pandas/_libs/tslibs/nattype.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ cdef class _NaT(datetime):
166166

167167
elif util.is_integer_object(other):
168168
# For Period compat
169-
# TODO: the integer behavior is deprecated, remove it
170169
return c_NaT
171170

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

202201
elif util.is_integer_object(other):
203202
# For Period compat
204-
# TODO: the integer behavior is deprecated, remove it
205203
return c_NaT
206204

207205
elif util.is_array(other):

pandas/_libs/tslibs/parsing.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ def try_parse_date_and_time(
671671
object[:] result
672672

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

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

737737
n = len(years)
738-
# TODO(cython 3.0): Use len instead of `shape[0]`
738+
# TODO(cython3): Use len instead of `shape[0]`
739739
if (
740740
months.shape[0] != n
741741
or days.shape[0] != n

pandas/core/window/rolling.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def __init__(
136136
self.window = window
137137
self.min_periods = min_periods
138138
self.center = center
139-
# TODO: Change this back to self.win_type once deprecation is enforced
139+
# TODO(2.0): Change this back to self.win_type once deprecation is enforced
140140
self._win_type = win_type
141141
self.axis = obj._get_axis_number(axis) if axis is not None else None
142142
self.method = method
@@ -262,7 +262,7 @@ def _gotitem(self, key, ndim, subset=None):
262262
# we need to make a shallow copy of ourselves
263263
# with the same groupby
264264
with warnings.catch_warnings():
265-
# TODO: Remove once win_type deprecation is enforced
265+
# TODO(2.0): Remove once win_type deprecation is enforced
266266
warnings.filterwarnings("ignore", "win_type", FutureWarning)
267267
kwargs = {attr: getattr(self, attr) for attr in self._attributes}
268268

pandas/io/parsers/readers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ def read_csv(
606606
# Error Handling
607607
error_bad_lines=None,
608608
warn_bad_lines=None,
609-
# TODO (2.0): set on_bad_lines to "error".
609+
# TODO(2.0): set on_bad_lines to "error".
610610
# See _refine_defaults_read comment for why we do this.
611611
on_bad_lines=None,
612612
# Internal
@@ -704,7 +704,7 @@ def read_table(
704704
# Error Handling
705705
error_bad_lines=None,
706706
warn_bad_lines=None,
707-
# TODO (2.0): set on_bad_lines to "error".
707+
# TODO(2.0): set on_bad_lines to "error".
708708
# See _refine_defaults_read comment for why we do this.
709709
on_bad_lines=None,
710710
# Internal

pandas/io/stata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ def convert_delta_safe(base, deltas, unit) -> Series:
338338
deltas = to_timedelta(deltas, unit=unit)
339339
return base + deltas
340340

341-
# TODO: If/when pandas supports more than datetime64[ns], this should be
342-
# improved to use correct range, e.g. datetime[Y] for yearly
341+
# TODO(non-nano): If/when pandas supports more than datetime64[ns], this
342+
# should be improved to use correct range, e.g. datetime[Y] for yearly
343343
bad_locs = np.isnan(dates)
344344
has_bad_values = False
345345
if bad_locs.any():

pandas/tests/arrays/sparse/test_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ def test_from_coo(self):
12031203
row = [0, 3, 1, 0]
12041204
col = [0, 3, 1, 2]
12051205
data = [4, 5, 7, 9]
1206-
# TODO: Remove dtype when scipy is fixed
1206+
# TODO(scipy#13585): Remove dtype when scipy is fixed
12071207
# https://github.com/scipy/scipy/issues/13585
12081208
sp_array = scipy.sparse.coo_matrix((data, (row, col)), dtype="int")
12091209
result = pd.Series.sparse.from_coo(sp_array)

pandas/tests/frame/methods/test_join.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,14 @@ def test_join_index_more(float_frame):
143143

144144
def test_join_index_series(float_frame):
145145
df = float_frame.copy()
146-
s = df.pop(float_frame.columns[-1])
147-
joined = df.join(s)
146+
ser = df.pop(float_frame.columns[-1])
147+
joined = df.join(ser)
148148

149-
# TODO should this check_names ?
150-
tm.assert_frame_equal(joined, float_frame, check_names=False)
149+
tm.assert_frame_equal(joined, float_frame)
151150

152-
s.name = None
151+
ser.name = None
153152
with pytest.raises(ValueError, match="must have a name"):
154-
df.join(s)
153+
df.join(ser)
155154

156155

157156
def test_join_overlap(float_frame):
@@ -241,8 +240,7 @@ def test_join(self, multiindex_dataframe_random_data):
241240

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

244-
# TODO what should join do with names ?
245-
tm.assert_frame_equal(joined, expected, check_names=False)
243+
tm.assert_frame_equal(joined, expected)
246244

247245
def test_join_segfault(self):
248246
# GH#1532

pandas/tests/frame/methods/test_reset_index.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,32 +144,31 @@ def test_reset_index(self, float_frame):
144144
df = float_frame.reset_index().set_index(["index", "A", "B"])
145145
rs = df.reset_index(["A", "B"])
146146

147-
# TODO should reset_index check_names ?
148-
tm.assert_frame_equal(rs, float_frame, check_names=False)
147+
tm.assert_frame_equal(rs, float_frame)
149148

150149
rs = df.reset_index(["index", "A", "B"])
151-
tm.assert_frame_equal(rs, float_frame.reset_index(), check_names=False)
150+
tm.assert_frame_equal(rs, float_frame.reset_index())
152151

153152
rs = df.reset_index(["index", "A", "B"])
154-
tm.assert_frame_equal(rs, float_frame.reset_index(), check_names=False)
153+
tm.assert_frame_equal(rs, float_frame.reset_index())
155154

156155
rs = df.reset_index("A")
157156
xp = float_frame.reset_index().set_index(["index", "B"])
158-
tm.assert_frame_equal(rs, xp, check_names=False)
157+
tm.assert_frame_equal(rs, xp)
159158

160159
# test resetting in place
161160
df = float_frame.copy()
162161
reset = float_frame.reset_index()
163162
return_value = df.reset_index(inplace=True)
164163
assert return_value is None
165-
tm.assert_frame_equal(df, reset, check_names=False)
164+
tm.assert_frame_equal(df, reset)
166165

167166
df = float_frame.reset_index().set_index(["index", "A", "B"])
168167
rs = df.reset_index("A", drop=True)
169168
xp = float_frame.copy()
170169
del xp["A"]
171170
xp = xp.set_index(["B"], append=True)
172-
tm.assert_frame_equal(rs, xp, check_names=False)
171+
tm.assert_frame_equal(rs, xp)
173172

174173
def test_reset_index_name(self):
175174
df = DataFrame(

pandas/tests/frame/test_constructors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2528,7 +2528,7 @@ def check_views():
25282528
else:
25292529
# TODO: we can call check_views if we stop consolidating
25302530
# in setitem_with_indexer
2531-
# FIXME: enable after GH#35417
2531+
# FIXME(GH#35417): enable after GH#35417
25322532
# assert b[0] == 0
25332533
assert df.iloc[0, 2] == 0
25342534

pandas/tests/groupby/test_allowlist.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import numpy as np
99
import pytest
1010

11-
import pandas.util._test_decorators as td
12-
1311
from pandas import (
1412
DataFrame,
1513
Index,
@@ -359,8 +357,7 @@ def test_groupby_function_rename(mframe):
359357
"cummax",
360358
"cummin",
361359
"cumprod",
362-
# TODO(ArrayManager) quantile
363-
pytest.param("describe", marks=td.skip_array_manager_not_yet_implemented),
360+
"describe",
364361
"rank",
365362
"quantile",
366363
"diff",

pandas/tests/indexes/test_indexing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class TestGetValue:
172172
"index", ["string", "int", "datetime", "timedelta"], indirect=True
173173
)
174174
def test_get_value(self, index):
175-
# TODO: Remove function? GH#19728
175+
# TODO(2.0): can remove once get_value deprecation is enforced GH#19728
176176
values = np.random.randn(100)
177177
value = index[67]
178178

pandas/tests/io/test_sql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2042,7 +2042,7 @@ def test_to_sql_with_negative_npinf(self, input, request):
20422042
# GH 36465
20432043
# The input {"foo": [-np.inf], "infe0": ["bar"]} does not raise any error
20442044
# for pymysql version >= 0.10
2045-
# TODO: remove this version check after GH 36465 is fixed
2045+
# TODO(GH#36465): remove this version check after GH 36465 is fixed
20462046
import pymysql
20472047

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

0 commit comments

Comments
 (0)