Skip to content

Commit 097322f

Browse files
authored
CLN: FIXMEs (pandas-dev#44771)
1 parent e6f0d1d commit 097322f

File tree

17 files changed

+86
-113
lines changed

17 files changed

+86
-113
lines changed

pandas/_config/config.py

-1
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,6 @@ def _warn_if_deprecated(key: str) -> bool:
642642
d = _get_deprecated_option(key)
643643
if d:
644644
if d.msg:
645-
print(d.msg)
646645
warnings.warn(d.msg, FutureWarning)
647646
else:
648647
msg = f"'{key}' is deprecated"

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6024,7 +6024,7 @@ def _convert(
60246024
timedelta: bool_t = False,
60256025
) -> NDFrameT:
60266026
"""
6027-
Attempt to infer better dtype for object columns
6027+
Attempt to infer better dtype for object columns.
60286028
60296029
Parameters
60306030
----------

pandas/core/indexes/datetimes.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,8 @@ def get_loc(self, key, method=None, tolerance=None):
647647
try:
648648
key = self._maybe_cast_for_get_loc(key)
649649
except ValueError as err:
650-
# FIXME: we get here because parse_with_reso doesn't raise on "t2m"
650+
# FIXME(dateutil#1180): we get here because parse_with_reso
651+
# doesn't raise on "t2m"
651652
raise KeyError(key) from err
652653

653654
elif isinstance(key, timedelta):

pandas/core/internals/blocks.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1797,9 +1797,7 @@ def fillna(
17971797
value, limit, inplace, downcast
17981798
)
17991799

1800-
values = self.values
1801-
values = values if inplace else values.copy()
1802-
new_values = values.fillna(value=value, limit=limit)
1800+
new_values = self.values.fillna(value=value, limit=limit)
18031801
return [self.make_block_same_class(values=new_values)]
18041802

18051803

pandas/core/internals/concat.py

-1
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,6 @@ def _get_empty_dtype(join_units: Sequence[JoinUnit]) -> DtypeObj:
528528
return blk.dtype
529529

530530
if _is_uniform_reindex(join_units):
531-
# FIXME: integrate property
532531
empty_dtype = join_units[0].block.dtype
533532
return empty_dtype
534533

pandas/io/clipboard/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ def determine_clipboard():
518518
"cygwin" in platform.system().lower()
519519
): # Cygwin has a variety of values returned by platform.system(),
520520
# such as 'CYGWIN_NT-6.1'
521-
# FIXME: pyperclip currently does not support Cygwin,
521+
# FIXME(pyperclip#55): pyperclip currently does not support Cygwin,
522522
# see https://github.com/asweigart/pyperclip/issues/55
523523
if os.path.exists("/dev/clipboard"):
524524
warnings.warn(

pandas/tests/arrays/floating/test_construction.py

-6
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ def test_floating_array_disallows_float16(request):
5656
with pytest.raises(TypeError, match=msg):
5757
FloatingArray(arr, mask)
5858

59-
if not np_version_under1p19:
60-
# Troubleshoot
61-
# https://github.com/numpy/numpy/issues/20512#issuecomment-985807740
62-
lowered = np.core._type_aliases.english_lower("Float16")
63-
assert lowered == "float16", lowered
64-
6559
if np_version_under1p19 or (
6660
locale.getlocale()[0] != "en_US" and not is_platform_windows()
6761
):

pandas/tests/extension/base/getitem.py

+16-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pytest
33

44
import pandas as pd
5+
import pandas._testing as tm
56
from pandas.tests.extension.base.base import BaseExtensionTests
67

78

@@ -258,12 +259,22 @@ def test_getitem_integer_with_missing_raises(self, data, idx):
258259
with pytest.raises(ValueError, match=msg):
259260
data[idx]
260261

261-
# FIXME: dont leave commented-out
262+
@pytest.mark.xfail(
263+
reason="Tries label-based and raises KeyError; "
264+
"in some cases raises when calling np.asarray"
265+
)
266+
@pytest.mark.parametrize(
267+
"idx",
268+
[[0, 1, 2, pd.NA], pd.array([0, 1, 2, pd.NA], dtype="Int64")],
269+
ids=["list", "integer-array"],
270+
)
271+
def test_getitem_series_integer_with_missing_raises(self, data, idx):
272+
msg = "Cannot index with an integer indexer containing NA values"
262273
# TODO: this raises KeyError about labels not found (it tries label-based)
263-
# import pandas._testing as tm
264-
# ser = pd.Series(data, index=[tm.rands(4) for _ in range(len(data))])
265-
# with pytest.raises(ValueError, match=msg):
266-
# ser[idx]
274+
275+
ser = pd.Series(data, index=[tm.rands(4) for _ in range(len(data))])
276+
with pytest.raises(ValueError, match=msg):
277+
ser[idx]
267278

268279
def test_getitem_slice(self, data):
269280
# getitem[slice] should return an array

pandas/tests/indexes/multi/test_setops.py

+17-9
Original file line numberDiff line numberDiff line change
@@ -260,17 +260,24 @@ def test_union(idx, sort):
260260
else:
261261
assert result.equals(idx)
262262

263-
# FIXME: don't leave commented-out
264-
# not valid for python 3
265-
# def test_union_with_regular_index(self):
266-
# other = Index(['A', 'B', 'C'])
267263

268-
# result = other.union(idx)
269-
# assert ('foo', 'one') in result
270-
# assert 'B' in result
264+
@pytest.mark.xfail(
265+
# This test was commented out from Oct 2011 to Dec 2021, may no longer
266+
# be relevant.
267+
reason="Length of names must match number of levels in MultiIndex",
268+
raises=ValueError,
269+
)
270+
def test_union_with_regular_index(idx):
271+
other = Index(["A", "B", "C"])
271272

272-
# result2 = _index.union(other)
273-
# assert result.equals(result2)
273+
result = other.union(idx)
274+
assert ("foo", "one") in result
275+
assert "B" in result
276+
277+
msg = "The values in the array are unorderable"
278+
with tm.assert_produces_warning(RuntimeWarning, match=msg):
279+
result2 = idx.union(other)
280+
assert result.equals(result2)
274281

275282

276283
def test_intersection(idx, sort):
@@ -355,6 +362,7 @@ def test_union_sort_other_empty(slice_):
355362
other = idx[slice_]
356363
tm.assert_index_equal(idx.union(other), idx)
357364
# MultiIndex does not special case empty.union(idx)
365+
# FIXME: don't leave commented-out
358366
# tm.assert_index_equal(other.union(idx), idx)
359367

360368
# sort=False

pandas/tests/indexes/period/test_indexing.py

+17-20
Original file line numberDiff line numberDiff line change
@@ -193,20 +193,18 @@ def test_getitem_seconds(self):
193193
"2013/02/01 9H",
194194
"2013/02/01 09:00",
195195
]
196-
for v in values:
196+
for val in values:
197197
# GH7116
198198
# these show deprecations as we are trying
199199
# to slice with non-integer indexers
200-
# FIXME: don't leave commented-out
201-
# with pytest.raises(IndexError):
202-
# idx[v]
203-
continue
200+
with pytest.raises(IndexError, match="only integers, slices"):
201+
idx[val]
204202

205-
s = Series(np.random.rand(len(idx)), index=idx)
206-
tm.assert_series_equal(s["2013/01/01 10:00"], s[3600:3660])
207-
tm.assert_series_equal(s["2013/01/01 9H"], s[:3600])
203+
ser = Series(np.random.rand(len(idx)), index=idx)
204+
tm.assert_series_equal(ser["2013/01/01 10:00"], ser[3600:3660])
205+
tm.assert_series_equal(ser["2013/01/01 9H"], ser[:3600])
208206
for d in ["2013/01/01", "2013/01", "2013"]:
209-
tm.assert_series_equal(s[d], s)
207+
tm.assert_series_equal(ser[d], ser)
210208

211209
def test_getitem_day(self):
212210
# GH#6716
@@ -223,24 +221,23 @@ def test_getitem_day(self):
223221
"2013/02/01 9H",
224222
"2013/02/01 09:00",
225223
]
226-
for v in values:
224+
for val in values:
227225

228226
# GH7116
229227
# these show deprecations as we are trying
230228
# to slice with non-integer indexers
231-
# with pytest.raises(IndexError):
232-
# idx[v]
233-
continue
229+
with pytest.raises(IndexError, match="only integers, slices"):
230+
idx[val]
234231

235-
s = Series(np.random.rand(len(idx)), index=idx)
236-
tm.assert_series_equal(s["2013/01"], s[0:31])
237-
tm.assert_series_equal(s["2013/02"], s[31:59])
238-
tm.assert_series_equal(s["2014"], s[365:])
232+
ser = Series(np.random.rand(len(idx)), index=idx)
233+
tm.assert_series_equal(ser["2013/01"], ser[0:31])
234+
tm.assert_series_equal(ser["2013/02"], ser[31:59])
235+
tm.assert_series_equal(ser["2014"], ser[365:])
239236

240237
invalid = ["2013/02/01 9H", "2013/02/01 09:00"]
241-
for v in invalid:
242-
with pytest.raises(KeyError, match=v):
243-
s[v]
238+
for val in invalid:
239+
with pytest.raises(KeyError, match=val):
240+
ser[val]
244241

245242

246243
class TestGetLoc:

pandas/tests/indexing/multiindex/test_partial.py

-22
Original file line numberDiff line numberDiff line change
@@ -169,28 +169,6 @@ def test_getitem_intkey_leading_level(
169169
with tm.assert_produces_warning(FutureWarning):
170170
mi.get_value(ser, 14)
171171

172-
# ---------------------------------------------------------------------
173-
# AMBIGUOUS CASES!
174-
175-
def test_partial_loc_missing(self, multiindex_year_month_day_dataframe_random_data):
176-
pytest.skip("skipping for now")
177-
178-
ymd = multiindex_year_month_day_dataframe_random_data
179-
result = ymd.loc[2000, 0]
180-
expected = ymd.loc[2000]["A"]
181-
tm.assert_series_equal(result, expected)
182-
183-
# need to put in some work here
184-
# FIXME: dont leave commented-out
185-
# self.ymd.loc[2000, 0] = 0
186-
# assert (self.ymd.loc[2000]['A'] == 0).all()
187-
188-
# Pretty sure the second (and maybe even the first) is already wrong.
189-
with pytest.raises(KeyError, match="6"):
190-
ymd.loc[(2000, 6)]
191-
with pytest.raises(KeyError, match="(2000, 6)"):
192-
ymd.loc[(2000, 6), 0]
193-
194172
# ---------------------------------------------------------------------
195173

196174
def test_setitem_multiple_partial(self, multiindex_dataframe_random_data):

pandas/tests/indexing/test_coercion.py

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ def _assert_setitem_series_conversion(
8888
# check dtype explicitly for sure
8989
assert temp.dtype == expected_dtype
9090

91+
# AFAICT the problem is in Series.__setitem__ where with integer dtype
92+
# ser[1] = 2.2 casts 2.2 to 2 instead of casting the ser to floating
9193
# FIXME: dont leave commented-out
9294
# .loc works different rule, temporary disable
9395
# temp = original_series.copy()

pandas/tests/indexing/test_floats.py

+8-19
Original file line numberDiff line numberDiff line change
@@ -68,27 +68,16 @@ def test_scalar_non_numeric(self, index_func, frame_or_series, indexer_sl):
6868
# contains
6969
assert 3.0 not in s
7070

71-
# setting with an indexer
72-
if s.index.inferred_type in ["categorical"]:
73-
# Value or Type Error
74-
pass
75-
elif s.index.inferred_type in ["datetime64", "timedelta64", "period"]:
76-
77-
# FIXME: dont leave commented-out
78-
# these should prob work
79-
# and are inconsistent between series/dataframe ATM
80-
# for idxr in [lambda x: x]:
81-
# s2 = s.copy()
82-
#
83-
# with pytest.raises(TypeError):
84-
# idxr(s2)[3.0] = 0
85-
pass
71+
s2 = s.copy()
72+
indexer_sl(s2)[3.0] = 10
8673

74+
if indexer_sl is tm.setitem:
75+
assert 3.0 in s2.axes[-1]
76+
elif indexer_sl is tm.loc:
77+
assert 3.0 in s2.axes[0]
8778
else:
88-
89-
s2 = s.copy()
90-
indexer_sl(s2)[3.0] = 10
91-
assert s2.index.is_object()
79+
assert 3.0 not in s2.axes[0]
80+
assert 3.0 not in s2.axes[-1]
9281

9382
@pytest.mark.parametrize(
9483
"index_func",

pandas/tests/io/excel/test_writers.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,10 @@ def test_datetimes(self, path):
11061106
write_frame = DataFrame({"A": datetimes})
11071107
write_frame.to_excel(path, "Sheet1")
11081108
if path.endswith("xlsx") or path.endswith("xlsm"):
1109-
pytest.skip("Defaults to openpyxl and fails - GH #38644")
1109+
pytest.skip(
1110+
"Defaults to openpyxl and fails with floating point error on "
1111+
"datetimes; may be fixed on newer versions of openpyxl - GH #38644"
1112+
)
11101113
read_frame = pd.read_excel(path, sheet_name="Sheet1", header=0)
11111114

11121115
tm.assert_series_equal(write_frame["A"], read_frame["A"])

pandas/tests/series/methods/test_convert.py

-6
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,6 @@ def test_convert(self):
113113
result = ser._convert(datetime=True)
114114
tm.assert_series_equal(result, ser)
115115

116-
# FIXME: dont leave commented-out
117-
# res = ser.copy()
118-
# res[0] = np.nan
119-
# result = res._convert(datetime=True, numeric=False)
120-
# assert result.dtype == 'M8[ns]'
121-
122116
def test_convert_no_arg_error(self):
123117
ser = Series(["1.0", "2"])
124118
msg = r"At least one of datetime, numeric or timedelta must be True\."

pandas/tests/series/test_missing.py

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from datetime import timedelta
22

33
import numpy as np
4+
import pytest
45

56
from pandas._libs import iNaT
67

@@ -73,20 +74,23 @@ def test_timedelta64_nan(self):
7374
td1[2] = td[2]
7475
assert not isna(td1[2])
7576

76-
# FIXME: don't leave commented-out
7777
# boolean setting
78-
# this doesn't work, not sure numpy even supports it
79-
# result = td[(td>np.timedelta64(timedelta(days=3))) &
80-
# td<np.timedelta64(timedelta(days=7)))] = np.nan
81-
# assert isna(result).sum() == 7
82-
78+
# GH#2899 boolean setting
79+
td3 = np.timedelta64(timedelta(days=3))
80+
td7 = np.timedelta64(timedelta(days=7))
81+
td[(td > td3) & (td < td7)] = np.nan
82+
assert isna(td).sum() == 3
83+
84+
@pytest.mark.xfail(
85+
reason="Chained inequality raises when trying to define 'selector'"
86+
)
87+
def test_logical_range_select(self, datetime_series):
8388
# NumPy limitation =(
84-
85-
# def test_logical_range_select(self):
86-
# np.random.seed(12345)
87-
# selector = -0.5 <= datetime_series <= 0.5
88-
# expected = (datetime_series >= -0.5) & (datetime_series <= 0.5)
89-
# tm.assert_series_equal(selector, expected)
89+
# https://github.com/pandas-dev/pandas/commit/9030dc021f07c76809848925cb34828f6c8484f3
90+
np.random.seed(12345)
91+
selector = -0.5 <= datetime_series <= 0.5
92+
expected = (datetime_series >= -0.5) & (datetime_series <= 0.5)
93+
tm.assert_series_equal(selector, expected)
9094

9195
def test_valid(self, datetime_series):
9296
ts = datetime_series.copy()

pandas/tests/series/test_ufunc.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,7 @@ def test_reduce(values, box, request):
278278
# ATM Index casts to object, so we get python ints/floats
279279
same_type = False
280280

281-
if values.dtype == "i8" and box is pd.array:
282-
# FIXME: pd.array casts to Int64
283-
obj = values
284-
else:
285-
obj = box(values)
281+
obj = box(values)
286282

287283
result = np.maximum.reduce(obj)
288284
expected = values[1]

0 commit comments

Comments
 (0)