Skip to content

Commit f31c2b3

Browse files
authored
CLN: TODOs (#44733)
1 parent 8eb0b1b commit f31c2b3

File tree

14 files changed

+47
-65
lines changed

14 files changed

+47
-65
lines changed

pandas/tests/arrays/boolean/test_construction.py

-16
Original file line numberDiff line numberDiff line change
@@ -321,19 +321,3 @@ def test_to_numpy_copy():
321321
result = arr.to_numpy(dtype=bool, copy=True)
322322
result[0] = False
323323
tm.assert_extension_array_equal(arr, pd.array([True, False, True], dtype="boolean"))
324-
325-
326-
# FIXME: don't leave commented out
327-
# TODO when BooleanArray coerces to object dtype numpy array, need to do conversion
328-
# manually in the indexing code
329-
# def test_indexing_boolean_mask():
330-
# arr = pd.array([1, 2, 3, 4], dtype="Int64")
331-
# mask = pd.array([True, False, True, False], dtype="boolean")
332-
# result = arr[mask]
333-
# expected = pd.array([1, 3], dtype="Int64")
334-
# tm.assert_extension_array_equal(result, expected)
335-
336-
# # missing values -> error
337-
# mask = pd.array([True, False, True, None], dtype="boolean")
338-
# with pytest.raises(IndexError):
339-
# result = arr[mask]

pandas/tests/arrays/masked/test_arithmetic.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import pandas as pd
99
import pandas._testing as tm
10-
from pandas.core.arrays import ExtensionArray
1110

1211
# integer dtypes
1312
arrays = [pd.array([1, 2, 3, None], dtype=dtype) for dtype in tm.ALL_INT_EA_DTYPES]
@@ -71,11 +70,7 @@ def test_numpy_array_equivalence(data, all_arithmetic_operators):
7170

7271
result = op(data, numpy_array)
7372
expected = op(data, pd_array)
74-
if isinstance(expected, ExtensionArray):
75-
tm.assert_extension_array_equal(result, expected)
76-
else:
77-
# TODO div still gives float ndarray -> remove this once we have Float EA
78-
tm.assert_numpy_array_equal(result, expected)
73+
tm.assert_extension_array_equal(result, expected)
7974

8075

8176
# Test equivalence with Series and DataFrame ops

pandas/tests/extension/test_sparse.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,14 @@ def test_where_series(self, data, na_value):
328328
expected = pd.Series(cls._from_sequence([a, b, b, b], dtype=data.dtype))
329329
self.assert_series_equal(result, expected)
330330

331-
def test_combine_first(self, data):
331+
def test_combine_first(self, data, request):
332332
if data.dtype.subtype == "int":
333333
# Right now this is upcasted to float, just like combine_first
334334
# for Series[int]
335-
pytest.skip("TODO(SparseArray.__setitem__ will preserve dtype.")
335+
mark = pytest.mark.xfail(
336+
reason="TODO(SparseArray.__setitem__) will preserve dtype."
337+
)
338+
request.node.add_marker(mark)
336339
super().test_combine_first(data)
337340

338341
def test_searchsorted(self, data_for_sorting, as_series):

pandas/tests/frame/methods/test_align.py

-6
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ def test_align_float(self, float_frame):
5555
# test fill value
5656
join_idx = float_frame.index.join(other.index)
5757
diff_a = float_frame.index.difference(join_idx)
58-
diff_b = other.index.difference(join_idx)
5958
diff_a_vals = af.reindex(diff_a).values
60-
diff_b_vals = bf.reindex(diff_b).values
6159
assert (diff_a_vals == -1).all()
6260

6361
af, bf = float_frame.align(other, join="right", axis=0)
@@ -74,12 +72,8 @@ def test_align_float(self, float_frame):
7472
# test fill value
7573
join_idx = float_frame.index.join(other.index)
7674
diff_a = float_frame.index.difference(join_idx)
77-
diff_b = other.index.difference(join_idx)
7875
diff_a_vals = af.reindex(diff_a).values
7976

80-
# TODO(wesm): unused?
81-
diff_b_vals = bf.reindex(diff_b).values # noqa
82-
8377
assert (diff_a_vals == -1).all()
8478

8579
af, bf = float_frame.align(other, join="inner", axis=1)

pandas/tests/frame/methods/test_quantile.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ def test_quantile_item_cache(self, using_array_manager):
571571

572572
class TestQuantileExtensionDtype:
573573
# TODO: tests for axis=1?
574-
# TODO: empty case? might as well do dt64 and td64 here too
574+
# TODO: empty case?
575575

576576
@pytest.fixture(
577577
params=[
@@ -581,6 +581,7 @@ class TestQuantileExtensionDtype:
581581
),
582582
pd.period_range("2016-01-01", periods=9, freq="D"),
583583
pd.date_range("2016-01-01", periods=9, tz="US/Pacific"),
584+
pd.timedelta_range("1 Day", periods=9),
584585
pd.array(np.arange(9), dtype="Int64"),
585586
pd.array(np.arange(9), dtype="Float64"),
586587
],
@@ -650,7 +651,18 @@ def test_quantile_ea_with_na(self, obj, index):
650651

651652
# TODO(GH#39763): filtering can be removed after GH#39763 is fixed
652653
@pytest.mark.filterwarnings("ignore:Using .astype to convert:FutureWarning")
653-
def test_quantile_ea_all_na(self, obj, index, frame_or_series):
654+
def test_quantile_ea_all_na(
655+
self, obj, index, frame_or_series, using_array_manager, request
656+
):
657+
if (
658+
using_array_manager
659+
and frame_or_series is DataFrame
660+
and index.dtype == "m8[ns]"
661+
):
662+
mark = pytest.mark.xfail(
663+
reason="obj.astype fails bc obj is incorrectly dt64 at this point"
664+
)
665+
request.node.add_marker(mark)
654666

655667
obj.iloc[:] = index._na_value
656668

pandas/tests/groupby/test_apply.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def test_apply_frame_not_as_index_column_name(df):
360360
grouped = df.groupby(["A", "B"], as_index=False)
361361
result = grouped.apply(len)
362362
expected = grouped.count().rename(columns={"C": np.nan}).drop(columns="D")
363-
# TODO: Use assert_frame_equal when column name is not np.nan (GH 36306)
363+
# TODO(GH#34306): Use assert_frame_equal when column name is not np.nan
364364
tm.assert_index_equal(result.index, expected.index)
365365
tm.assert_numpy_array_equal(result.values, expected.values)
366366

@@ -1134,9 +1134,8 @@ def test_positional_slice_groups_datetimelike():
11341134
tm.assert_frame_equal(result, expected)
11351135

11361136

1137-
def test_doctest_example2():
1137+
def test_groupby_apply_shape_cache_safety():
11381138
# GH#42702 this fails if we cache_readonly Block.shape
1139-
# TODO: more informative name
11401139
df = DataFrame({"A": ["a", "a", "b"], "B": [1, 2, 3], "C": [4, 6, 5]})
11411140
gb = df.groupby("A")
11421141
result = gb[["B", "C"]].apply(lambda x: x.astype(float).max() - x.min())

pandas/tests/indexes/datetimes/test_constructors.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,20 @@ def test_shallow_copy_inherits_array_freq(self, index):
6969

7070
def test_categorical_preserves_tz(self):
7171
# GH#18664 retain tz when going DTI-->Categorical-->DTI
72-
# TODO: parametrize over DatetimeIndex/DatetimeArray
73-
# once pd.CategoricalIndex(DTA) works
74-
7572
dti = DatetimeIndex(
7673
[pd.NaT, "2015-01-01", "1999-04-06 15:14:13", "2015-01-01"], tz="US/Eastern"
7774
)
7875

79-
ci = pd.CategoricalIndex(dti)
80-
carr = pd.Categorical(dti)
81-
cser = pd.Series(ci)
76+
for dtobj in [dti, dti._data]:
77+
# works for DatetimeIndex or DatetimeArray
78+
79+
ci = pd.CategoricalIndex(dtobj)
80+
carr = pd.Categorical(dtobj)
81+
cser = pd.Series(ci)
8282

83-
for obj in [ci, carr, cser]:
84-
result = DatetimeIndex(obj)
85-
tm.assert_index_equal(result, dti)
83+
for obj in [ci, carr, cser]:
84+
result = DatetimeIndex(obj)
85+
tm.assert_index_equal(result, dti)
8686

8787
def test_dti_with_period_data_raises(self):
8888
# GH#23675

pandas/tests/indexes/test_base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1364,9 +1364,9 @@ def test_str_to_bytes_raises(self):
13641364
@pytest.mark.filterwarnings("ignore:elementwise comparison failed:FutureWarning")
13651365
def test_index_with_tuple_bool(self):
13661366
# GH34123
1367-
# TODO: remove tupleize_cols=False once correct behaviour is restored
13681367
# TODO: also this op right now produces FutureWarning from numpy
1369-
idx = Index([("a", "b"), ("b", "c"), ("c", "a")], tupleize_cols=False)
1368+
# https://github.com/numpy/numpy/issues/11521
1369+
idx = Index([("a", "b"), ("b", "c"), ("c", "a")])
13701370
result = idx == ("c", "a")
13711371
expected = np.array([False, False, True])
13721372
tm.assert_numpy_array_equal(result, expected)

pandas/tests/indexes/test_setops.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,9 @@ def test_intersection_difference_match_empty(self, index, sort):
453453
@pytest.mark.parametrize(
454454
"method", ["intersection", "union", "difference", "symmetric_difference"]
455455
)
456-
def test_setop_with_categorical(index, sort, method):
457-
if isinstance(index, MultiIndex): # TODO: flat_index?
458-
# tested separately in tests.indexes.multi.test_setops
459-
return
456+
def test_setop_with_categorical(index_flat, sort, method):
457+
# MultiIndex tested separately in tests.indexes.multi.test_setops
458+
index = index_flat
460459

461460
other = index.astype("category")
462461
exact = "equiv" if isinstance(index, RangeIndex) else True

pandas/tests/indexing/test_chaining_and_caching.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -502,8 +502,8 @@ def test_iloc_setitem_chained_assignment(self):
502502

503503
df["bb"].iloc[0] = 0.13
504504

505-
# TODO: unused
506-
df_tmp = df.iloc[ck] # noqa
505+
# GH#3970 this lookup used to break the chained setting to 0.15
506+
df.iloc[ck]
507507

508508
df["bb"].iloc[0] = 0.15
509509
assert df["bb"].iloc[0] == 0.15

pandas/tests/indexing/test_indexing.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,11 @@ def test_dups_fancy_indexing_across_dtypes(self):
232232
df.head()
233233
str(df)
234234
result = DataFrame([[1, 2, 1.0, 2.0, 3.0, "foo", "bar"]])
235-
result.columns = list("aaaaaaa")
235+
result.columns = list("aaaaaaa") # GH#3468
236236

237-
# TODO(wesm): unused?
238-
df_v = df.iloc[:, 4] # noqa
239-
res_v = result.iloc[:, 4] # noqa
237+
# GH#3509 smoke tests for indexing with duplicate columns
238+
df.iloc[:, 4]
239+
result.iloc[:, 4]
240240

241241
tm.assert_frame_equal(df, result)
242242

pandas/tests/indexing/test_loc.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ def test_loc_getitem_single_boolean_arg(self, obj, key, exp):
199199
assert res == exp
200200

201201

202-
class TestLoc2:
203-
# TODO: better name, just separating out things that rely on base class
202+
class TestLocBaseIndependent:
203+
# Tests for loc that do not depend on subclassing Base
204204
@pytest.mark.parametrize(
205205
"msg, key",
206206
[

pandas/tests/series/indexing/test_getitem.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ def test_getitem_int64(self, datetime_series):
110110
idx = np.int64(5)
111111
assert datetime_series[idx] == datetime_series[5]
112112

113-
# TODO: better name/GH ref?
114-
def test_getitem_regression(self):
113+
def test_getitem_full_range(self):
114+
# github.com/pandas-dev/pandas/commit/4f433773141d2eb384325714a2776bcc5b2e20f7
115115
ser = Series(range(5), index=list(range(5)))
116116
result = ser[list(range(5))]
117117
tm.assert_series_equal(result, ser)
@@ -240,7 +240,6 @@ def test_getitem_partial_str_slice_high_reso_with_timedeltaindex(self):
240240
result = ser["1 days, 10:11:12.001001"]
241241
assert result == ser.iloc[1001]
242242

243-
# TODO: redundant with test_getitem_ndim_deprecated?
244243
def test_getitem_slice_2d(self, datetime_series):
245244
# GH#30588 multi-dimensional indexing deprecated
246245

pandas/tests/series/test_arithmetic.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from pandas import (
1717
Categorical,
1818
Index,
19-
IntervalIndex,
2019
Series,
2120
Timedelta,
2221
bdate_range,
@@ -828,9 +827,7 @@ def test_series_inplace_ops(self, dtype1, dtype2, dtype_expected, dtype_mul):
828827

829828
def test_none_comparison(series_with_simple_index):
830829
series = series_with_simple_index
831-
if isinstance(series.index, IntervalIndex):
832-
# IntervalIndex breaks on "series[0] = np.nan" below
833-
pytest.skip("IntervalIndex doesn't support assignment")
830+
834831
if len(series) < 1:
835832
pytest.skip("Test doesn't make sense on empty data")
836833

0 commit comments

Comments
 (0)