Skip to content

Commit

Permalink
CLN: TODOs (#44733)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Dec 3, 2021
1 parent 8eb0b1b commit f31c2b3
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 65 deletions.
16 changes: 0 additions & 16 deletions pandas/tests/arrays/boolean/test_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,19 +321,3 @@ def test_to_numpy_copy():
result = arr.to_numpy(dtype=bool, copy=True)
result[0] = False
tm.assert_extension_array_equal(arr, pd.array([True, False, True], dtype="boolean"))


# FIXME: don't leave commented out
# TODO when BooleanArray coerces to object dtype numpy array, need to do conversion
# manually in the indexing code
# def test_indexing_boolean_mask():
# arr = pd.array([1, 2, 3, 4], dtype="Int64")
# mask = pd.array([True, False, True, False], dtype="boolean")
# result = arr[mask]
# expected = pd.array([1, 3], dtype="Int64")
# tm.assert_extension_array_equal(result, expected)

# # missing values -> error
# mask = pd.array([True, False, True, None], dtype="boolean")
# with pytest.raises(IndexError):
# result = arr[mask]
7 changes: 1 addition & 6 deletions pandas/tests/arrays/masked/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import pandas as pd
import pandas._testing as tm
from pandas.core.arrays import ExtensionArray

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

result = op(data, numpy_array)
expected = op(data, pd_array)
if isinstance(expected, ExtensionArray):
tm.assert_extension_array_equal(result, expected)
else:
# TODO div still gives float ndarray -> remove this once we have Float EA
tm.assert_numpy_array_equal(result, expected)
tm.assert_extension_array_equal(result, expected)


# Test equivalence with Series and DataFrame ops
Expand Down
7 changes: 5 additions & 2 deletions pandas/tests/extension/test_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,14 @@ def test_where_series(self, data, na_value):
expected = pd.Series(cls._from_sequence([a, b, b, b], dtype=data.dtype))
self.assert_series_equal(result, expected)

def test_combine_first(self, data):
def test_combine_first(self, data, request):
if data.dtype.subtype == "int":
# Right now this is upcasted to float, just like combine_first
# for Series[int]
pytest.skip("TODO(SparseArray.__setitem__ will preserve dtype.")
mark = pytest.mark.xfail(
reason="TODO(SparseArray.__setitem__) will preserve dtype."
)
request.node.add_marker(mark)
super().test_combine_first(data)

def test_searchsorted(self, data_for_sorting, as_series):
Expand Down
6 changes: 0 additions & 6 deletions pandas/tests/frame/methods/test_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ def test_align_float(self, float_frame):
# test fill value
join_idx = float_frame.index.join(other.index)
diff_a = float_frame.index.difference(join_idx)
diff_b = other.index.difference(join_idx)
diff_a_vals = af.reindex(diff_a).values
diff_b_vals = bf.reindex(diff_b).values
assert (diff_a_vals == -1).all()

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

# TODO(wesm): unused?
diff_b_vals = bf.reindex(diff_b).values # noqa

assert (diff_a_vals == -1).all()

af, bf = float_frame.align(other, join="inner", axis=1)
Expand Down
16 changes: 14 additions & 2 deletions pandas/tests/frame/methods/test_quantile.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ def test_quantile_item_cache(self, using_array_manager):

class TestQuantileExtensionDtype:
# TODO: tests for axis=1?
# TODO: empty case? might as well do dt64 and td64 here too
# TODO: empty case?

@pytest.fixture(
params=[
Expand All @@ -581,6 +581,7 @@ class TestQuantileExtensionDtype:
),
pd.period_range("2016-01-01", periods=9, freq="D"),
pd.date_range("2016-01-01", periods=9, tz="US/Pacific"),
pd.timedelta_range("1 Day", periods=9),
pd.array(np.arange(9), dtype="Int64"),
pd.array(np.arange(9), dtype="Float64"),
],
Expand Down Expand Up @@ -650,7 +651,18 @@ def test_quantile_ea_with_na(self, obj, index):

# TODO(GH#39763): filtering can be removed after GH#39763 is fixed
@pytest.mark.filterwarnings("ignore:Using .astype to convert:FutureWarning")
def test_quantile_ea_all_na(self, obj, index, frame_or_series):
def test_quantile_ea_all_na(
self, obj, index, frame_or_series, using_array_manager, request
):
if (
using_array_manager
and frame_or_series is DataFrame
and index.dtype == "m8[ns]"
):
mark = pytest.mark.xfail(
reason="obj.astype fails bc obj is incorrectly dt64 at this point"
)
request.node.add_marker(mark)

obj.iloc[:] = index._na_value

Expand Down
5 changes: 2 additions & 3 deletions pandas/tests/groupby/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def test_apply_frame_not_as_index_column_name(df):
grouped = df.groupby(["A", "B"], as_index=False)
result = grouped.apply(len)
expected = grouped.count().rename(columns={"C": np.nan}).drop(columns="D")
# TODO: Use assert_frame_equal when column name is not np.nan (GH 36306)
# TODO(GH#34306): Use assert_frame_equal when column name is not np.nan
tm.assert_index_equal(result.index, expected.index)
tm.assert_numpy_array_equal(result.values, expected.values)

Expand Down Expand Up @@ -1134,9 +1134,8 @@ def test_positional_slice_groups_datetimelike():
tm.assert_frame_equal(result, expected)


def test_doctest_example2():
def test_groupby_apply_shape_cache_safety():
# GH#42702 this fails if we cache_readonly Block.shape
# TODO: more informative name
df = DataFrame({"A": ["a", "a", "b"], "B": [1, 2, 3], "C": [4, 6, 5]})
gb = df.groupby("A")
result = gb[["B", "C"]].apply(lambda x: x.astype(float).max() - x.min())
Expand Down
18 changes: 9 additions & 9 deletions pandas/tests/indexes/datetimes/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,20 @@ def test_shallow_copy_inherits_array_freq(self, index):

def test_categorical_preserves_tz(self):
# GH#18664 retain tz when going DTI-->Categorical-->DTI
# TODO: parametrize over DatetimeIndex/DatetimeArray
# once pd.CategoricalIndex(DTA) works

dti = DatetimeIndex(
[pd.NaT, "2015-01-01", "1999-04-06 15:14:13", "2015-01-01"], tz="US/Eastern"
)

ci = pd.CategoricalIndex(dti)
carr = pd.Categorical(dti)
cser = pd.Series(ci)
for dtobj in [dti, dti._data]:
# works for DatetimeIndex or DatetimeArray

ci = pd.CategoricalIndex(dtobj)
carr = pd.Categorical(dtobj)
cser = pd.Series(ci)

for obj in [ci, carr, cser]:
result = DatetimeIndex(obj)
tm.assert_index_equal(result, dti)
for obj in [ci, carr, cser]:
result = DatetimeIndex(obj)
tm.assert_index_equal(result, dti)

def test_dti_with_period_data_raises(self):
# GH#23675
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexes/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1364,9 +1364,9 @@ def test_str_to_bytes_raises(self):
@pytest.mark.filterwarnings("ignore:elementwise comparison failed:FutureWarning")
def test_index_with_tuple_bool(self):
# GH34123
# TODO: remove tupleize_cols=False once correct behaviour is restored
# TODO: also this op right now produces FutureWarning from numpy
idx = Index([("a", "b"), ("b", "c"), ("c", "a")], tupleize_cols=False)
# https://github.com/numpy/numpy/issues/11521
idx = Index([("a", "b"), ("b", "c"), ("c", "a")])
result = idx == ("c", "a")
expected = np.array([False, False, True])
tm.assert_numpy_array_equal(result, expected)
Expand Down
7 changes: 3 additions & 4 deletions pandas/tests/indexes/test_setops.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,9 @@ def test_intersection_difference_match_empty(self, index, sort):
@pytest.mark.parametrize(
"method", ["intersection", "union", "difference", "symmetric_difference"]
)
def test_setop_with_categorical(index, sort, method):
if isinstance(index, MultiIndex): # TODO: flat_index?
# tested separately in tests.indexes.multi.test_setops
return
def test_setop_with_categorical(index_flat, sort, method):
# MultiIndex tested separately in tests.indexes.multi.test_setops
index = index_flat

other = index.astype("category")
exact = "equiv" if isinstance(index, RangeIndex) else True
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexing/test_chaining_and_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,8 @@ def test_iloc_setitem_chained_assignment(self):

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

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

df["bb"].iloc[0] = 0.15
assert df["bb"].iloc[0] == 0.15
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,11 @@ def test_dups_fancy_indexing_across_dtypes(self):
df.head()
str(df)
result = DataFrame([[1, 2, 1.0, 2.0, 3.0, "foo", "bar"]])
result.columns = list("aaaaaaa")
result.columns = list("aaaaaaa") # GH#3468

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

tm.assert_frame_equal(df, result)

Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexing/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ def test_loc_getitem_single_boolean_arg(self, obj, key, exp):
assert res == exp


class TestLoc2:
# TODO: better name, just separating out things that rely on base class
class TestLocBaseIndependent:
# Tests for loc that do not depend on subclassing Base
@pytest.mark.parametrize(
"msg, key",
[
Expand Down
5 changes: 2 additions & 3 deletions pandas/tests/series/indexing/test_getitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def test_getitem_int64(self, datetime_series):
idx = np.int64(5)
assert datetime_series[idx] == datetime_series[5]

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

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

Expand Down
5 changes: 1 addition & 4 deletions pandas/tests/series/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from pandas import (
Categorical,
Index,
IntervalIndex,
Series,
Timedelta,
bdate_range,
Expand Down Expand Up @@ -828,9 +827,7 @@ def test_series_inplace_ops(self, dtype1, dtype2, dtype_expected, dtype_mul):

def test_none_comparison(series_with_simple_index):
series = series_with_simple_index
if isinstance(series.index, IntervalIndex):
# IntervalIndex breaks on "series[0] = np.nan" below
pytest.skip("IntervalIndex doesn't support assignment")

if len(series) < 1:
pytest.skip("Test doesn't make sense on empty data")

Expand Down

0 comments on commit f31c2b3

Please sign in to comment.