Skip to content

Commit 41d2a35

Browse files
jbrockmendelrhshadrach
authored andcommitted
CLN: address FIXME/TODO/XXX comments (pandas-dev#33858)
1 parent 8593dd4 commit 41d2a35

File tree

30 files changed

+36
-52
lines changed

30 files changed

+36
-52
lines changed

ci/setup_env.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ conda list pandas
128128
echo "[Build extensions]"
129129
python setup.py build_ext -q -i -j2
130130

131-
# XXX: Some of our environments end up with old versions of pip (10.x)
131+
# TODO: Some of our environments end up with old versions of pip (10.x)
132132
# Adding a new enough version of pip to the requirements explodes the
133133
# solve time. Just using pip to update itself.
134134
# - py35_macos

pandas/_libs/src/parser/tokenizer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ See LICENSE for the license
5252
#define PARSER_OUT_OF_MEMORY -1
5353

5454
/*
55-
* XXX Might want to couple count_rows() with read_rows() to avoid duplication
56-
* of some file I/O.
55+
* TODO: Might want to couple count_rows() with read_rows() to avoid
56+
* duplication of some file I/O.
5757
*/
5858

5959
typedef enum {

pandas/_libs/tslibs/strptime.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ class TimeRE(dict):
544544
'w': r"(?P<w>[0-6])",
545545
# W is set below by using 'U'
546546
'y': r"(?P<y>\d\d)",
547-
# XXX: Does 'Y' need to worry about having less or more than
547+
# TODO: Does 'Y' need to worry about having less or more than
548548
# 4 digits?
549549
'Y': r"(?P<Y>\d\d\d\d)",
550550
'z': r"(?P<z>[+-]\d\d:?[0-5]\d(:?[0-5]\d(\.\d{1,6})?)?|Z)",

pandas/core/algorithms.py

+1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ def _ensure_data(values, dtype=None):
142142
if values.ndim > 1 and is_datetime64_ns_dtype(values):
143143
# Avoid calling the DatetimeIndex constructor as it is 1D only
144144
# Note: this is reached by DataFrame.rank calls GH#27027
145+
# TODO(EA2D): special case not needed with 2D EAs
145146
asi8 = values.view("i8")
146147
dtype = values.dtype
147148
return asi8, dtype

pandas/core/arrays/sparse/array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def __init__(
335335
# TODO: disentangle the fill_value dtype inference from
336336
# dtype inference
337337
if data is None:
338-
# XXX: What should the empty dtype be? Object or float?
338+
# TODO: What should the empty dtype be? Object or float?
339339
data = np.array([], dtype=dtype)
340340

341341
if not is_array_like(data):

pandas/core/dtypes/concat.py

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ def concat_categorical(to_concat, axis: int = 0):
178178
]
179179
result = concat_compat(to_concat)
180180
if axis == 1:
181+
# TODO(EA2D): not necessary with 2D EAs
181182
result = result.reshape(1, len(result))
182183
return result
183184

pandas/core/groupby/generic.py

+1
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,7 @@ def _cython_agg_blocks(
11291129
# e.g. block.values was an IntegerArray
11301130
# (1, N) case can occur if block.values was Categorical
11311131
# and result is ndarray[object]
1132+
# TODO(EA2D): special casing not needed with 2D EAs
11321133
assert result.ndim == 1 or result.shape[0] == 1
11331134
try:
11341135
# Cast back if feasible

pandas/core/groupby/ops.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ def _cython_operation(
476476

477477
if is_datetime64tz_dtype(values.dtype):
478478
# Cast to naive; we'll cast back at the end of the function
479-
# TODO: possible need to reshape? kludge can be avoided when
480-
# 2D EA is allowed.
479+
# TODO: possible need to reshape?
480+
# TODO(EA2D):kludge can be avoided when 2D EA is allowed.
481481
values = values.view("M8[ns]")
482482

483483
is_datetimelike = needs_i8_conversion(values.dtype)
@@ -717,7 +717,7 @@ def _aggregate_series_pure_python(
717717
if isinstance(res, (Series, Index, np.ndarray)):
718718
if len(res) == 1:
719719
# e.g. test_agg_lambda_with_timezone lambda e: e.head(1)
720-
# FIXME: are we potentially losing import res.index info?
720+
# FIXME: are we potentially losing important res.index info?
721721
res = res.item()
722722
else:
723723
raise ValueError("Function does not reduce")

pandas/core/internals/blocks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1721,7 +1721,7 @@ def take_nd(
17211721
return self.make_block_same_class(new_values, new_mgr_locs)
17221722

17231723
def _can_hold_element(self, element: Any) -> bool:
1724-
# XXX: We may need to think about pushing this onto the array.
1724+
# TODO: We may need to think about pushing this onto the array.
17251725
# We're doing the same as CategoricalBlock here.
17261726
return True
17271727

pandas/core/internals/concat.py

+1
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ def is_na(self):
218218
elif is_sparse(self.block.values.dtype):
219219
return False
220220
elif self.block.is_extension:
221+
# TODO(EA2D): no need for special case with 2D EAs
221222
values_flat = values
222223
else:
223224
values_flat = values.ravel(order="K")

pandas/io/parsers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,7 @@ def _cast_types(self, values, cast_type, column):
18511851
)
18521852

18531853
if not is_object_dtype(values) and not known_cats:
1854-
# XXX this is for consistency with
1854+
# TODO: this is for consistency with
18551855
# c-parser which parses all categories
18561856
# as strings
18571857
values = astype_nansafe(values, str)

pandas/tests/arithmetic/test_datetime64.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,10 @@ def test_dt64arr_nat_comparison(self, tz_naive_fixture, box_with_array):
140140
ts = pd.Timestamp.now(tz)
141141
ser = pd.Series([ts, pd.NaT])
142142

143-
# FIXME: Can't transpose because that loses the tz dtype on
144-
# the NaT column
145-
obj = tm.box_expected(ser, box, transpose=False)
143+
obj = tm.box_expected(ser, box)
146144

147145
expected = pd.Series([True, False], dtype=np.bool_)
148-
expected = tm.box_expected(expected, xbox, transpose=False)
146+
expected = tm.box_expected(expected, xbox)
149147

150148
result = obj == ts
151149
tm.assert_equal(result, expected)
@@ -843,10 +841,8 @@ def test_dt64arr_add_sub_td64_nat(self, box_with_array, tz_naive_fixture):
843841
other = np.timedelta64("NaT")
844842
expected = pd.DatetimeIndex(["NaT"] * 9, tz=tz)
845843

846-
# FIXME: fails with transpose=True due to tz-aware DataFrame
847-
# transpose bug
848-
obj = tm.box_expected(dti, box_with_array, transpose=False)
849-
expected = tm.box_expected(expected, box_with_array, transpose=False)
844+
obj = tm.box_expected(dti, box_with_array)
845+
expected = tm.box_expected(expected, box_with_array)
850846

851847
result = obj + other
852848
tm.assert_equal(result, expected)

pandas/tests/arithmetic/test_period.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -906,9 +906,8 @@ def test_pi_add_offset_n_gt1_not_divisible(self, box_with_array):
906906
pi = pd.PeriodIndex(["2016-01"], freq="2M")
907907
expected = pd.PeriodIndex(["2016-04"], freq="2M")
908908

909-
# FIXME: with transposing these tests fail
910-
pi = tm.box_expected(pi, box_with_array, transpose=False)
911-
expected = tm.box_expected(expected, box_with_array, transpose=False)
909+
pi = tm.box_expected(pi, box_with_array)
910+
expected = tm.box_expected(expected, box_with_array)
912911

913912
result = pi + to_offset("3M")
914913
tm.assert_equal(result, expected)

pandas/tests/arrays/boolean/test_logical.py

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def test_empty_ok(self, all_logical_operators):
3838
result = getattr(a, op_name)(False)
3939
tm.assert_extension_array_equal(a, result)
4040

41+
# FIXME: dont leave commented-out
4142
# TODO: pd.NA
4243
# result = getattr(a, op_name)(pd.NA)
4344
# tm.assert_extension_array_equal(a, result)

pandas/tests/base/test_conversion.py

-4
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ class TestToIterable:
4848
],
4949
ids=["tolist", "to_list", "list", "iter"],
5050
)
51-
@pytest.mark.filterwarnings("ignore:\\n Passing:FutureWarning")
52-
# TODO(GH-24559): Remove the filterwarnings
5351
def test_iterable(self, index_or_series, method, dtype, rdtype):
5452
# gh-10904
5553
# gh-13258
@@ -104,8 +102,6 @@ def test_iterable_items(self, dtype, rdtype):
104102
@pytest.mark.parametrize(
105103
"dtype, rdtype", dtypes + [("object", int), ("category", int)]
106104
)
107-
@pytest.mark.filterwarnings("ignore:\\n Passing:FutureWarning")
108-
# TODO(GH-24559): Remove the filterwarnings
109105
def test_iterable_map(self, index_or_series, dtype, rdtype):
110106
# gh-13236
111107
# coerce iteration to underlying python / pandas types

pandas/tests/extension/base/dtype.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_check_dtype(self, data):
7575
else:
7676
expected = pd.Series([True, True, False, False], index=list("ABCD"))
7777

78-
# XXX: This should probably be *fixed* not ignored.
78+
# FIXME: This should probably be *fixed* not ignored.
7979
# See libops.scalar_compare
8080
with warnings.catch_warnings():
8181
warnings.simplefilter("ignore", DeprecationWarning)

pandas/tests/extension/base/getitem.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ def test_getitem_integer_with_missing_raises(self, data, idx):
230230
with pytest.raises(ValueError, match=msg):
231231
data[idx]
232232

233-
# TODO this raises KeyError about labels not found (it tries label-based)
233+
# FIXME: dont leave commented-out
234+
# TODO: this raises KeyError about labels not found (it tries label-based)
234235
# import pandas._testing as tm
235236
# s = pd.Series(data, index=[tm.rands(4) for _ in range(len(data))])
236237
# with pytest.raises(ValueError, match=msg):

pandas/tests/extension/test_boolean.py

+1
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ class TestUnaryOps(base.BaseUnaryOpsTests):
346346
pass
347347

348348

349+
# FIXME: dont leave commented-out
349350
# TODO parsing not yet supported
350351
# class TestParsing(base.BaseParsingTests):
351352
# pass

pandas/tests/frame/methods/test_round.py

-5
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,6 @@ def test_round(self):
102102
# nan in Series round
103103
nan_round_Series = Series({"col1": np.nan, "col2": 1})
104104

105-
# TODO(wesm): unused?
106-
expected_nan_round = DataFrame( # noqa
107-
{"col1": [1.123, 2.123, 3.123], "col2": [1.2, 2.2, 3.2]}
108-
)
109-
110105
msg = "integer argument expected, got float"
111106
with pytest.raises(TypeError, match=msg):
112107
df.round(nan_round_Series)

pandas/tests/indexes/common.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,7 @@ def test_equals(self, indices):
561561
assert not indices.equals(np.array(indices))
562562

563563
# Cannot pass in non-int64 dtype to RangeIndex
564-
if not isinstance(indices, (RangeIndex, CategoricalIndex)):
565-
# TODO: CategoricalIndex can be re-allowed following GH#32167
564+
if not isinstance(indices, RangeIndex):
566565
same_values = Index(indices, dtype=object)
567566
assert indices.equals(same_values)
568567
assert same_values.equals(indices)

pandas/tests/indexes/datetimes/test_date_range.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ def test_daterange_bug_456(self):
846846
# GH #456
847847
rng1 = bdate_range("12/5/2011", "12/5/2011")
848848
rng2 = bdate_range("12/2/2011", "12/5/2011")
849-
rng2._data.freq = BDay() # TODO: shouldn't this already be set?
849+
assert rng2._data.freq == BDay()
850850

851851
result = rng1.union(rng2)
852852
assert isinstance(result, DatetimeIndex)
@@ -905,7 +905,7 @@ def test_daterange_bug_456(self):
905905
# GH #456
906906
rng1 = bdate_range("12/5/2011", "12/5/2011", freq="C")
907907
rng2 = bdate_range("12/2/2011", "12/5/2011", freq="C")
908-
rng2._data.freq = CDay() # TODO: shouldn't this already be set?
908+
assert rng2._data.freq == CDay()
909909

910910
result = rng1.union(rng2)
911911
assert isinstance(result, DatetimeIndex)

pandas/tests/indexing/test_chaining_and_caching.py

-3
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,6 @@ def test_cache_updating(self):
376376
df["f"] = 0
377377
df.f.values[3] = 1
378378

379-
# TODO(wesm): unused?
380-
# y = df.iloc[np.arange(2, len(df))]
381-
382379
df.f.values[3] = 2
383380
expected = DataFrame(
384381
np.zeros((5, 6), dtype="int64"),

pandas/tests/io/excel/test_style.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
)
2424
def test_styler_to_excel(engine):
2525
def style(df):
26-
# XXX: RGB colors not supported in xlwt
26+
# TODO: RGB colors not supported in xlwt
2727
return DataFrame(
2828
[
2929
["font-weight: bold", "", ""],
@@ -47,7 +47,7 @@ def assert_equal_style(cell1, cell2, engine):
4747
pytest.xfail(
4848
reason=(f"GH25351: failing on some attribute comparisons in {engine}")
4949
)
50-
# XXX: should find a better way to check equality
50+
# TODO: should find a better way to check equality
5151
assert cell1.alignment.__dict__ == cell2.alignment.__dict__
5252
assert cell1.border.__dict__ == cell2.border.__dict__
5353
assert cell1.fill.__dict__ == cell2.fill.__dict__
@@ -98,15 +98,15 @@ def custom_converter(css):
9898

9999
# (2) check styling with default converter
100100

101-
# XXX: openpyxl (as at 2.4) prefixes colors with 00, xlsxwriter with FF
101+
# TODO: openpyxl (as at 2.4) prefixes colors with 00, xlsxwriter with FF
102102
alpha = "00" if engine == "openpyxl" else "FF"
103103

104104
n_cells = 0
105105
for col1, col2 in zip(wb["frame"].columns, wb["styled"].columns):
106106
assert len(col1) == len(col2)
107107
for cell1, cell2 in zip(col1, col2):
108108
ref = f"{cell2.column}{cell2.row:d}"
109-
# XXX: this isn't as strong a test as ideal; we should
109+
# TODO: this isn't as strong a test as ideal; we should
110110
# confirm that differences are exclusive
111111
if ref == "B2":
112112
assert not cell1.font.bold

pandas/tests/io/formats/test_css.py

-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ def test_css_parse_invalid(invalid_css, remainder):
6060
with tm.assert_produces_warning(CSSWarning):
6161
assert_same_resolution(invalid_css, remainder)
6262

63-
# TODO: we should be checking that in other cases no warnings are raised
64-
6563

6664
@pytest.mark.parametrize(
6765
"shorthand,expansions",

pandas/tests/io/test_sql.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ def setup_method(self, load_iris_data):
11301130
self.conn.close()
11311131
self.conn = self.__engine
11321132
self.pandasSQL = sql.SQLDatabase(self.__engine)
1133-
# XXX:
1133+
# FIXME: dont leave commented-out
11341134
# super().teardown_method(method)
11351135

11361136

pandas/tests/reshape/test_concat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def test_concatlike_dtypes_coercion(self):
228228
# same dtype is tested in test_concatlike_same_dtypes
229229
continue
230230
elif typ1 == "category" or typ2 == "category":
231-
# ToDo: suspicious
231+
# TODO: suspicious
232232
continue
233233

234234
# specify expected dtype

pandas/tests/scalar/timedelta/test_arithmetic.py

-1
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,6 @@ def test_td_rfloordiv_numeric_series(self):
652652
msg = "Invalid dtype"
653653
with pytest.raises(TypeError, match=msg):
654654
# Deprecated GH#19761, enforced GH#29797
655-
# TODO: GH-19761. Change to TypeError.
656655
ser // td
657656

658657
# ----------------------------------------------------------------

pandas/tests/series/indexing/test_datetime.py

-2
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,6 @@ def test_indexing_unordered():
556556
ts2 = pd.concat([ts[0:4], ts[-4:], ts[4:-4]])
557557

558558
for t in ts.index:
559-
# TODO: unused?
560-
s = str(t) # noqa
561559

562560
expected = ts[t]
563561
result = ts2[t]

pandas/tests/series/indexing/test_indexing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def test_setitem_with_tz(tz):
445445

446446

447447
def test_setitem_with_tz_dst():
448-
# GH XXX
448+
# GH XXX TODO: fill in GH ref
449449
tz = "US/Eastern"
450450
orig = pd.Series(pd.date_range("2016-11-06", freq="H", periods=3, tz=tz))
451451
assert orig.dtype == f"datetime64[ns, {tz}]"

pandas/tseries/offsets.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def rollforward(self, dt):
435435
def is_on_offset(self, dt):
436436
if self.normalize and not _is_normalized(dt):
437437
return False
438-
# XXX, see #1395
438+
# TODO, see #1395
439439
if type(self) == DateOffset or isinstance(self, Tick):
440440
return True
441441

0 commit comments

Comments
 (0)