Skip to content

Commit 96bee9d

Browse files
authored
CLN: address TODOs and FIXMEs (#34033)
1 parent 0d3c5ce commit 96bee9d

File tree

9 files changed

+29
-26
lines changed

9 files changed

+29
-26
lines changed

pandas/core/arrays/categorical.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from pandas._config import get_option
99

10-
from pandas._libs import algos as libalgos, hashtable as htable
10+
from pandas._libs import NaT, algos as libalgos, hashtable as htable
1111
from pandas._typing import ArrayLike, Dtype, Ordered, Scalar
1212
from pandas.util._decorators import cache_readonly, deprecate_kwarg, doc
1313
from pandas.util._validators import validate_bool_kwarg, validate_fillna_kwargs
@@ -344,7 +344,7 @@ def __init__(
344344
) from err
345345
except ValueError as err:
346346

347-
# FIXME
347+
# TODO(EA2D)
348348
raise NotImplementedError(
349349
"> 1 ndim Categorical are not supported at this time"
350350
) from err
@@ -1425,7 +1425,7 @@ def _internal_get_values(self):
14251425
"""
14261426
# if we are a datetime and period index, return Index to keep metadata
14271427
if needs_i8_conversion(self.categories.dtype):
1428-
return self.categories.take(self._codes, fill_value=np.nan)
1428+
return self.categories.take(self._codes, fill_value=NaT)
14291429
elif is_integer_dtype(self.categories) and -1 in self._codes:
14301430
return self.categories.astype("object").take(self._codes, fill_value=np.nan)
14311431
return np.array(self)

pandas/core/config_init.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,7 @@ def _deprecate_negative_int_max_colwidth(key):
356356
)
357357

358358
cf.register_option(
359-
# FIXME: change `validator=is_nonnegative_int`
360-
# in version 1.2
359+
# TODO(2.0): change `validator=is_nonnegative_int` see GH#31569
361360
"max_colwidth",
362361
50,
363362
max_colwidth_doc,

pandas/core/dtypes/common.py

-2
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,6 @@ def is_period_dtype(arr_or_dtype) -> bool:
484484
# GH#33400 fastpath for dtype object
485485
return arr_or_dtype.type is Period
486486

487-
# TODO: Consider making Period an instance of PeriodDtype
488487
if arr_or_dtype is None:
489488
return False
490489
return PeriodDtype.is_dtype(arr_or_dtype)
@@ -523,7 +522,6 @@ def is_interval_dtype(arr_or_dtype) -> bool:
523522
# GH#33400 fastpath for dtype object
524523
return arr_or_dtype.type is Interval
525524

526-
# TODO: Consider making Interval an instance of IntervalDtype
527525
if arr_or_dtype is None:
528526
return False
529527
return IntervalDtype.is_dtype(arr_or_dtype)

pandas/core/frame.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -8338,9 +8338,7 @@ def blk_func(values):
83388338
assert len(res) == max(list(res.keys())) + 1, res.keys()
83398339
out = df._constructor_sliced(res, index=range(len(res)), dtype=out_dtype)
83408340
out.index = df.columns
8341-
if axis == 0 and df.dtypes.apply(needs_i8_conversion).any():
8342-
# FIXME: needs_i8_conversion check is kludge, not sure
8343-
# why it is necessary in this case and this case alone
8341+
if axis == 0 and is_object_dtype(out.dtype):
83448342
out[:] = coerce_to_dtypes(out.values, df.dtypes)
83458343
return out
83468344

pandas/core/internals/managers.py

-3
Original file line numberDiff line numberDiff line change
@@ -1284,9 +1284,6 @@ def _slice_take_blocks_ax0(self, slice_or_indexer, fill_value=lib.no_default):
12841284

12851285
# When filling blknos, make sure blknos is updated before appending to
12861286
# blocks list, that way new blkno is exactly len(blocks).
1287-
#
1288-
# FIXME: mgr_groupby_blknos must return mgr_locs in ascending order,
1289-
# pytables serialization will break otherwise.
12901287
blocks = []
12911288
for blkno, mgr_locs in libinternals.get_blkno_placements(blknos, group=True):
12921289
if blkno == -1:

pandas/tests/extension/test_boolean.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,13 @@ def test_error(self, data, all_arithmetic_operators):
148148
# other specific errors tested in the boolean array specific tests
149149
pass
150150

151-
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators):
151+
def test_arith_frame_with_scalar(self, data, all_arithmetic_operators, request):
152152
# frame & scalar
153153
op_name = all_arithmetic_operators
154-
if op_name in self.implements:
155-
super().test_arith_frame_with_scalar(data, all_arithmetic_operators)
156-
else:
157-
pytest.xfail("_reduce needs implementation")
154+
if op_name not in self.implements:
155+
mark = pytest.mark.xfail(reason="_reduce needs implementation")
156+
request.node.add_marker(mark)
157+
super().test_arith_frame_with_scalar(data, all_arithmetic_operators)
158158

159159

160160
class TestComparisonOps(base.BaseComparisonOpsTests):

pandas/tests/extension/test_numpy.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,30 @@ def test_take_series(self, data):
175175
# ValueError: PandasArray must be 1-dimensional.
176176
super().test_take_series(data)
177177

178-
def test_loc_iloc_frame_single_dtype(self, data):
178+
def test_loc_iloc_frame_single_dtype(self, data, request):
179179
npdtype = data.dtype.numpy_dtype
180180
if npdtype == object or npdtype == np.float64:
181181
# GH#33125
182-
pytest.xfail(reason="GH#33125 astype doesn't recognize data.dtype")
182+
mark = pytest.mark.xfail(
183+
reason="GH#33125 astype doesn't recognize data.dtype"
184+
)
185+
request.node.add_marker(mark)
183186
super().test_loc_iloc_frame_single_dtype(data)
184187

185188

186189
class TestGroupby(BaseNumPyTests, base.BaseGroupbyTests):
187190
@skip_nested
188-
def test_groupby_extension_apply(self, data_for_grouping, groupby_apply_op):
191+
def test_groupby_extension_apply(
192+
self, data_for_grouping, groupby_apply_op, request
193+
):
189194
# ValueError: Names should be list-like for a MultiIndex
190-
if data_for_grouping.dtype.numpy_dtype == np.float64:
191-
pytest.xfail(reason="GH#33125 astype doesn't recognize data.dtype")
195+
a = "a"
196+
is_identity = groupby_apply_op(a) is a
197+
if data_for_grouping.dtype.numpy_dtype == np.float64 and is_identity:
198+
mark = pytest.mark.xfail(
199+
reason="GH#33125 astype doesn't recognize data.dtype"
200+
)
201+
request.node.add_marker(mark)
192202
super().test_groupby_extension_apply(data_for_grouping, groupby_apply_op)
193203

194204

pandas/tests/groupby/test_categorical.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1260,15 +1260,16 @@ def test_get_nonexistent_category():
12601260

12611261

12621262
def test_series_groupby_on_2_categoricals_unobserved(
1263-
reduction_func: str, observed: bool
1263+
reduction_func: str, observed: bool, request
12641264
):
12651265
# GH 17605
12661266

12671267
if reduction_func == "ngroup":
12681268
pytest.skip("ngroup is not truly a reduction")
12691269

12701270
if reduction_func == "corrwith": # GH 32293
1271-
pytest.xfail("TODO: implemented SeriesGroupBy.corrwith")
1271+
mark = pytest.mark.xfail(reason="TODO: implemented SeriesGroupBy.corrwith")
1272+
request.node.add_marker(mark)
12721273

12731274
df = pd.DataFrame(
12741275
{

pandas/tests/test_downstream.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def test_pandas_gbq(df):
113113
pandas_gbq = import_module("pandas_gbq") # noqa
114114

115115

116-
@pytest.mark.xfail(reason="0.7.0 pending")
116+
@pytest.mark.xfail(reason="0.8.1 tries to import urlencode from pd.io.common")
117117
@tm.network
118118
def test_pandas_datareader():
119119

0 commit comments

Comments
 (0)