Skip to content

Commit

Permalink
CLN: FIXMEs (pandas-dev#44771)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored Dec 6, 2021
1 parent e6f0d1d commit 097322f
Show file tree
Hide file tree
Showing 17 changed files with 86 additions and 113 deletions.
1 change: 0 additions & 1 deletion pandas/_config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,6 @@ def _warn_if_deprecated(key: str) -> bool:
d = _get_deprecated_option(key)
if d:
if d.msg:
print(d.msg)
warnings.warn(d.msg, FutureWarning)
else:
msg = f"'{key}' is deprecated"
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6024,7 +6024,7 @@ def _convert(
timedelta: bool_t = False,
) -> NDFrameT:
"""
Attempt to infer better dtype for object columns
Attempt to infer better dtype for object columns.
Parameters
----------
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,8 @@ def get_loc(self, key, method=None, tolerance=None):
try:
key = self._maybe_cast_for_get_loc(key)
except ValueError as err:
# FIXME: we get here because parse_with_reso doesn't raise on "t2m"
# FIXME(dateutil#1180): we get here because parse_with_reso
# doesn't raise on "t2m"
raise KeyError(key) from err

elif isinstance(key, timedelta):
Expand Down
4 changes: 1 addition & 3 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1797,9 +1797,7 @@ def fillna(
value, limit, inplace, downcast
)

values = self.values
values = values if inplace else values.copy()
new_values = values.fillna(value=value, limit=limit)
new_values = self.values.fillna(value=value, limit=limit)
return [self.make_block_same_class(values=new_values)]


Expand Down
1 change: 0 additions & 1 deletion pandas/core/internals/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,6 @@ def _get_empty_dtype(join_units: Sequence[JoinUnit]) -> DtypeObj:
return blk.dtype

if _is_uniform_reindex(join_units):
# FIXME: integrate property
empty_dtype = join_units[0].block.dtype
return empty_dtype

Expand Down
2 changes: 1 addition & 1 deletion pandas/io/clipboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def determine_clipboard():
"cygwin" in platform.system().lower()
): # Cygwin has a variety of values returned by platform.system(),
# such as 'CYGWIN_NT-6.1'
# FIXME: pyperclip currently does not support Cygwin,
# FIXME(pyperclip#55): pyperclip currently does not support Cygwin,
# see https://github.com/asweigart/pyperclip/issues/55
if os.path.exists("/dev/clipboard"):
warnings.warn(
Expand Down
6 changes: 0 additions & 6 deletions pandas/tests/arrays/floating/test_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ def test_floating_array_disallows_float16(request):
with pytest.raises(TypeError, match=msg):
FloatingArray(arr, mask)

if not np_version_under1p19:
# Troubleshoot
# https://github.com/numpy/numpy/issues/20512#issuecomment-985807740
lowered = np.core._type_aliases.english_lower("Float16")
assert lowered == "float16", lowered

if np_version_under1p19 or (
locale.getlocale()[0] != "en_US" and not is_platform_windows()
):
Expand Down
21 changes: 16 additions & 5 deletions pandas/tests/extension/base/getitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest

import pandas as pd
import pandas._testing as tm
from pandas.tests.extension.base.base import BaseExtensionTests


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

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

ser = pd.Series(data, index=[tm.rands(4) for _ in range(len(data))])
with pytest.raises(ValueError, match=msg):
ser[idx]

def test_getitem_slice(self, data):
# getitem[slice] should return an array
Expand Down
26 changes: 17 additions & 9 deletions pandas/tests/indexes/multi/test_setops.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,24 @@ def test_union(idx, sort):
else:
assert result.equals(idx)

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

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

# result2 = _index.union(other)
# assert result.equals(result2)
result = other.union(idx)
assert ("foo", "one") in result
assert "B" in result

msg = "The values in the array are unorderable"
with tm.assert_produces_warning(RuntimeWarning, match=msg):
result2 = idx.union(other)
assert result.equals(result2)


def test_intersection(idx, sort):
Expand Down Expand Up @@ -355,6 +362,7 @@ def test_union_sort_other_empty(slice_):
other = idx[slice_]
tm.assert_index_equal(idx.union(other), idx)
# MultiIndex does not special case empty.union(idx)
# FIXME: don't leave commented-out
# tm.assert_index_equal(other.union(idx), idx)

# sort=False
Expand Down
37 changes: 17 additions & 20 deletions pandas/tests/indexes/period/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,18 @@ def test_getitem_seconds(self):
"2013/02/01 9H",
"2013/02/01 09:00",
]
for v in values:
for val in values:
# GH7116
# these show deprecations as we are trying
# to slice with non-integer indexers
# FIXME: don't leave commented-out
# with pytest.raises(IndexError):
# idx[v]
continue
with pytest.raises(IndexError, match="only integers, slices"):
idx[val]

s = Series(np.random.rand(len(idx)), index=idx)
tm.assert_series_equal(s["2013/01/01 10:00"], s[3600:3660])
tm.assert_series_equal(s["2013/01/01 9H"], s[:3600])
ser = Series(np.random.rand(len(idx)), index=idx)
tm.assert_series_equal(ser["2013/01/01 10:00"], ser[3600:3660])
tm.assert_series_equal(ser["2013/01/01 9H"], ser[:3600])
for d in ["2013/01/01", "2013/01", "2013"]:
tm.assert_series_equal(s[d], s)
tm.assert_series_equal(ser[d], ser)

def test_getitem_day(self):
# GH#6716
Expand All @@ -223,24 +221,23 @@ def test_getitem_day(self):
"2013/02/01 9H",
"2013/02/01 09:00",
]
for v in values:
for val in values:

# GH7116
# these show deprecations as we are trying
# to slice with non-integer indexers
# with pytest.raises(IndexError):
# idx[v]
continue
with pytest.raises(IndexError, match="only integers, slices"):
idx[val]

s = Series(np.random.rand(len(idx)), index=idx)
tm.assert_series_equal(s["2013/01"], s[0:31])
tm.assert_series_equal(s["2013/02"], s[31:59])
tm.assert_series_equal(s["2014"], s[365:])
ser = Series(np.random.rand(len(idx)), index=idx)
tm.assert_series_equal(ser["2013/01"], ser[0:31])
tm.assert_series_equal(ser["2013/02"], ser[31:59])
tm.assert_series_equal(ser["2014"], ser[365:])

invalid = ["2013/02/01 9H", "2013/02/01 09:00"]
for v in invalid:
with pytest.raises(KeyError, match=v):
s[v]
for val in invalid:
with pytest.raises(KeyError, match=val):
ser[val]


class TestGetLoc:
Expand Down
22 changes: 0 additions & 22 deletions pandas/tests/indexing/multiindex/test_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,28 +169,6 @@ def test_getitem_intkey_leading_level(
with tm.assert_produces_warning(FutureWarning):
mi.get_value(ser, 14)

# ---------------------------------------------------------------------
# AMBIGUOUS CASES!

def test_partial_loc_missing(self, multiindex_year_month_day_dataframe_random_data):
pytest.skip("skipping for now")

ymd = multiindex_year_month_day_dataframe_random_data
result = ymd.loc[2000, 0]
expected = ymd.loc[2000]["A"]
tm.assert_series_equal(result, expected)

# need to put in some work here
# FIXME: dont leave commented-out
# self.ymd.loc[2000, 0] = 0
# assert (self.ymd.loc[2000]['A'] == 0).all()

# Pretty sure the second (and maybe even the first) is already wrong.
with pytest.raises(KeyError, match="6"):
ymd.loc[(2000, 6)]
with pytest.raises(KeyError, match="(2000, 6)"):
ymd.loc[(2000, 6), 0]

# ---------------------------------------------------------------------

def test_setitem_multiple_partial(self, multiindex_dataframe_random_data):
Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/indexing/test_coercion.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def _assert_setitem_series_conversion(
# check dtype explicitly for sure
assert temp.dtype == expected_dtype

# AFAICT the problem is in Series.__setitem__ where with integer dtype
# ser[1] = 2.2 casts 2.2 to 2 instead of casting the ser to floating
# FIXME: dont leave commented-out
# .loc works different rule, temporary disable
# temp = original_series.copy()
Expand Down
27 changes: 8 additions & 19 deletions pandas/tests/indexing/test_floats.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,16 @@ def test_scalar_non_numeric(self, index_func, frame_or_series, indexer_sl):
# contains
assert 3.0 not in s

# setting with an indexer
if s.index.inferred_type in ["categorical"]:
# Value or Type Error
pass
elif s.index.inferred_type in ["datetime64", "timedelta64", "period"]:

# FIXME: dont leave commented-out
# these should prob work
# and are inconsistent between series/dataframe ATM
# for idxr in [lambda x: x]:
# s2 = s.copy()
#
# with pytest.raises(TypeError):
# idxr(s2)[3.0] = 0
pass
s2 = s.copy()
indexer_sl(s2)[3.0] = 10

if indexer_sl is tm.setitem:
assert 3.0 in s2.axes[-1]
elif indexer_sl is tm.loc:
assert 3.0 in s2.axes[0]
else:

s2 = s.copy()
indexer_sl(s2)[3.0] = 10
assert s2.index.is_object()
assert 3.0 not in s2.axes[0]
assert 3.0 not in s2.axes[-1]

@pytest.mark.parametrize(
"index_func",
Expand Down
5 changes: 4 additions & 1 deletion pandas/tests/io/excel/test_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,10 @@ def test_datetimes(self, path):
write_frame = DataFrame({"A": datetimes})
write_frame.to_excel(path, "Sheet1")
if path.endswith("xlsx") or path.endswith("xlsm"):
pytest.skip("Defaults to openpyxl and fails - GH #38644")
pytest.skip(
"Defaults to openpyxl and fails with floating point error on "
"datetimes; may be fixed on newer versions of openpyxl - GH #38644"
)
read_frame = pd.read_excel(path, sheet_name="Sheet1", header=0)

tm.assert_series_equal(write_frame["A"], read_frame["A"])
Expand Down
6 changes: 0 additions & 6 deletions pandas/tests/series/methods/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@ def test_convert(self):
result = ser._convert(datetime=True)
tm.assert_series_equal(result, ser)

# FIXME: dont leave commented-out
# res = ser.copy()
# res[0] = np.nan
# result = res._convert(datetime=True, numeric=False)
# assert result.dtype == 'M8[ns]'

def test_convert_no_arg_error(self):
ser = Series(["1.0", "2"])
msg = r"At least one of datetime, numeric or timedelta must be True\."
Expand Down
28 changes: 16 additions & 12 deletions pandas/tests/series/test_missing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import timedelta

import numpy as np
import pytest

from pandas._libs import iNaT

Expand Down Expand Up @@ -73,20 +74,23 @@ def test_timedelta64_nan(self):
td1[2] = td[2]
assert not isna(td1[2])

# FIXME: don't leave commented-out
# boolean setting
# this doesn't work, not sure numpy even supports it
# result = td[(td>np.timedelta64(timedelta(days=3))) &
# td<np.timedelta64(timedelta(days=7)))] = np.nan
# assert isna(result).sum() == 7

# GH#2899 boolean setting
td3 = np.timedelta64(timedelta(days=3))
td7 = np.timedelta64(timedelta(days=7))
td[(td > td3) & (td < td7)] = np.nan
assert isna(td).sum() == 3

@pytest.mark.xfail(
reason="Chained inequality raises when trying to define 'selector'"
)
def test_logical_range_select(self, datetime_series):
# NumPy limitation =(

# def test_logical_range_select(self):
# np.random.seed(12345)
# selector = -0.5 <= datetime_series <= 0.5
# expected = (datetime_series >= -0.5) & (datetime_series <= 0.5)
# tm.assert_series_equal(selector, expected)
# https://github.com/pandas-dev/pandas/commit/9030dc021f07c76809848925cb34828f6c8484f3
np.random.seed(12345)
selector = -0.5 <= datetime_series <= 0.5
expected = (datetime_series >= -0.5) & (datetime_series <= 0.5)
tm.assert_series_equal(selector, expected)

def test_valid(self, datetime_series):
ts = datetime_series.copy()
Expand Down
6 changes: 1 addition & 5 deletions pandas/tests/series/test_ufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,7 @@ def test_reduce(values, box, request):
# ATM Index casts to object, so we get python ints/floats
same_type = False

if values.dtype == "i8" and box is pd.array:
# FIXME: pd.array casts to Int64
obj = values
else:
obj = box(values)
obj = box(values)

result = np.maximum.reduce(obj)
expected = values[1]
Expand Down

0 comments on commit 097322f

Please sign in to comment.