Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ArrayManager] TST: Convert skip into xfail and clean-up tests that now work #44571

Merged
merged 2 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pandas/tests/frame/indexing/test_setitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,6 @@ def test_setitem_object_array_of_tzaware_datetimes(self, idx, expected):


class TestDataFrameSetItemWithExpansion:
# TODO(ArrayManager) update parent (_maybe_update_cacher)
@td.skip_array_manager_not_yet_implemented
def test_setitem_listlike_views(self):
# GH#38148
df = DataFrame({"a": [1, 2, 3], "b": [4, 4, 6]})
Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/frame/methods/test_fillna.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ def test_fillna_categorical_nan(self):
df = DataFrame({"a": Categorical(idx)})
tm.assert_frame_equal(df.fillna(value=NaT), df)

@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) implement downcast
def test_fillna_downcast(self):
# GH#15277
# infer int64 from float64
Expand All @@ -258,7 +257,6 @@ def test_fillna_dictlike_value_duplicate_colnames(self, columns):
expected["A"] = 0.0
tm.assert_frame_equal(result, expected)

@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) object upcasting
def test_fillna_dtype_conversion(self):
# make sure that fillna on an empty frame works
df = DataFrame(index=["A", "B", "C"], columns=[1, 2, 3, 4, 5])
Expand All @@ -276,7 +274,6 @@ def test_fillna_dtype_conversion(self):
expected = DataFrame("nan", index=range(3), columns=["A", "B"])
tm.assert_frame_equal(result, expected)

@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) object upcasting
@pytest.mark.parametrize("val", ["", 1, np.nan, 1.0])
def test_fillna_dtype_conversion_equiv_replace(self, val):
df = DataFrame({"A": [1, np.nan], "B": [1.0, 2.0]})
Expand Down
7 changes: 5 additions & 2 deletions pandas/tests/frame/methods/test_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,13 @@ def test_interp_string_axis(self, axis_name, axis_number):
expected = df.interpolate(method="linear", axis=axis_number)
tm.assert_frame_equal(result, expected)

@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) support axis=1
@pytest.mark.parametrize("method", ["ffill", "bfill", "pad"])
def test_interp_fillna_methods(self, axis, method):
def test_interp_fillna_methods(self, request, axis, method, using_array_manager):
# GH 12918
if using_array_manager and (axis == 1 or axis == "columns"):
# TODO(ArrayManager) support axis=1
td.mark_array_manager_not_yet_implemented(request)

df = DataFrame(
{
"A": [1.0, 2.0, 3.0, 4.0, np.nan, 5.0],
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/frame/methods/test_rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ def test_rename_mapper_and_positional_arguments_raises(self):
with pytest.raises(TypeError, match=msg):
df.rename({}, columns={}, index={})

@td.skip_array_manager_not_yet_implemented
def test_rename_with_duplicate_columns(self):
# GH#4403
df4 = DataFrame(
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/frame/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ def test_attrs(self):
result = df.rename(columns=str)
assert result.attrs == {"version": 1}

@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) setitem (no copy)
@pytest.mark.parametrize("allows_duplicate_labels", [True, False, None])
def test_set_flags(self, allows_duplicate_labels, frame_or_series):
obj = DataFrame({"A": [1, 2]})
Expand Down
18 changes: 14 additions & 4 deletions pandas/tests/frame/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,11 +722,16 @@ def test_df_add_2d_array_collike_broadcasts(self):
result = collike + df
tm.assert_frame_equal(result, expected)

@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) decide on dtypes
def test_df_arith_2d_array_rowlike_broadcasts(self, all_arithmetic_operators):
def test_df_arith_2d_array_rowlike_broadcasts(
self, request, all_arithmetic_operators, using_array_manager
):
# GH#23000
opname = all_arithmetic_operators

if using_array_manager and opname in ("__rmod__", "__rfloordiv__"):
# TODO(ArrayManager) decide on dtypes
td.mark_array_manager_not_yet_implemented(request)

arr = np.arange(6).reshape(3, 2)
df = DataFrame(arr, columns=[True, False], index=["A", "B", "C"])

Expand All @@ -744,11 +749,16 @@ def test_df_arith_2d_array_rowlike_broadcasts(self, all_arithmetic_operators):
result = getattr(df, opname)(rowlike)
tm.assert_frame_equal(result, expected)

@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) decide on dtypes
def test_df_arith_2d_array_collike_broadcasts(self, all_arithmetic_operators):
def test_df_arith_2d_array_collike_broadcasts(
self, request, all_arithmetic_operators, using_array_manager
):
# GH#23000
opname = all_arithmetic_operators

if using_array_manager and opname in ("__rmod__", "__rfloordiv__"):
# TODO(ArrayManager) decide on dtypes
td.mark_array_manager_not_yet_implemented(request)

arr = np.arange(6).reshape(3, 2)
df = DataFrame(arr, columns=[True, False], index=["A", "B", "C"])

Expand Down
10 changes: 6 additions & 4 deletions pandas/tests/frame/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2287,16 +2287,18 @@ def test_check_dtype_empty_numeric_column(self, dtype):

assert data.b.dtype == dtype

# TODO(ArrayManager) astype to bytes dtypes does not yet give object dtype
@td.skip_array_manager_not_yet_implemented
@pytest.mark.parametrize(
"dtype", tm.STRING_DTYPES + tm.BYTES_DTYPES + tm.OBJECT_DTYPES
)
def test_check_dtype_empty_string_column(self, dtype):
def test_check_dtype_empty_string_column(self, request, dtype, using_array_manager):
# GH24386: Ensure dtypes are set correctly for an empty DataFrame.
# Empty DataFrame is generated via dictionary data with non-overlapping columns.
data = DataFrame({"a": [1, 2]}, columns=["b"], dtype=dtype)

if using_array_manager and dtype in tm.BYTES_DTYPES:
# TODO(ArrayManager) astype to bytes dtypes does not yet give object dtype
td.mark_array_manager_not_yet_implemented(request)

assert data.b.dtype.name == "object"

def test_to_frame_with_falsey_names(self):
Expand Down Expand Up @@ -2466,7 +2468,7 @@ def test_constructor_list_str_na(self, string_dtype):
tm.assert_frame_equal(result, expected)

@pytest.mark.parametrize("copy", [False, True])
@td.skip_array_manager_not_yet_implemented
@td.skip_array_manager_invalid_test # TODO(ArrayManager)
jbrockmendel marked this conversation as resolved.
Show resolved Hide resolved
def test_dict_nocopy(self, copy, any_numeric_ea_dtype, any_numpy_dtype):
a = np.array([1, 2], dtype=any_numpy_dtype)
b = np.array([3, 4], dtype=any_numpy_dtype)
Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/frame/test_stack_unstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import numpy as np
import pytest

import pandas.util._test_decorators as td

import pandas as pd
from pandas import (
DataFrame,
Expand Down Expand Up @@ -949,7 +947,6 @@ def test_unstack_nan_index4(self):
left = df.loc[17264:].copy().set_index(["s_id", "dosage", "agent"])
tm.assert_frame_equal(left.unstack(), right)

@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) MultiIndex bug
def test_unstack_nan_index5(self):
# GH9497 - multiple unstack with nulls
df = DataFrame(
Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/groupby/aggregate/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import numpy as np
import pytest

import pandas.util._test_decorators as td

import pandas as pd
from pandas import (
DataFrame,
Expand Down Expand Up @@ -424,7 +422,6 @@ def __call__(self, x):
tm.assert_frame_equal(result, expected)


@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) columns with ndarrays
def test_agg_over_numpy_arrays():
# GH 3788
df = DataFrame(
Expand Down
6 changes: 1 addition & 5 deletions pandas/tests/groupby/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import numpy as np
import pytest

import pandas.util._test_decorators as td

import pandas as pd
from pandas import (
Categorical,
Expand Down Expand Up @@ -301,9 +299,7 @@ def test_apply(ordered):
tm.assert_series_equal(result, expected)


# TODO(ArrayManager) incorrect dtype for mean()
@td.skip_array_manager_not_yet_implemented
def test_observed(observed, using_array_manager):
def test_observed(observed):
# multiple groupers, don't re-expand the output space
# of the grouper
# gh-14942 (implement)
Expand Down
2 changes: 0 additions & 2 deletions pandas/tests/indexing/test_iloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ def test_iloc_setitem_fullcol_categorical(self, indexer, key, using_array_manage
expected = DataFrame({0: cat, 1: range(3)})
tm.assert_frame_equal(df, expected)

# TODO(ArrayManager) does not yet update parent
@td.skip_array_manager_not_yet_implemented
@pytest.mark.parametrize("box", [array, Series])
def test_iloc_setitem_ea_inplace(self, frame_or_series, box, using_array_manager):
# GH#38952 Case with not setting a full column
Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/indexing/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,9 +1143,6 @@ def test_loc_setitem_empty_append_single_value(self):
df.loc[0, "x"] = expected.loc[0, "x"]
tm.assert_frame_equal(df, expected)

# TODO(ArrayManager) "split" path doesn't handle this case and gives wrong
# error message
@td.skip_array_manager_not_yet_implemented
def test_loc_setitem_empty_append_raises(self):
# GH6173, various appends to an empty dataframe

Expand Down
6 changes: 0 additions & 6 deletions pandas/tests/indexing/test_partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import numpy as np
import pytest

import pandas.util._test_decorators as td

import pandas as pd
from pandas import (
DataFrame,
Expand Down Expand Up @@ -355,10 +353,6 @@ def test_partial_setting2(self):
df.at[dates[-1] + dates.freq, 0] = 7
tm.assert_frame_equal(df, expected)

# TODO(ArrayManager)
# df.loc[0] = Series(1, index=range(4)) case creates float columns
# instead of object dtype
@td.skip_array_manager_not_yet_implemented
def test_partial_setting_mixed_dtype(self):

# in a mixed dtype environment, try to preserve dtypes
Expand Down
6 changes: 0 additions & 6 deletions pandas/tests/io/json/test_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import numpy as np
import pytest

import pandas.util._test_decorators as td

from pandas import (
DataFrame,
Index,
Expand Down Expand Up @@ -153,8 +151,6 @@ def test_simple_records(self):

tm.assert_frame_equal(result, expected)

# TODO(ArrayManager) sanitize S/U numpy dtypes to object
@td.skip_array_manager_not_yet_implemented
def test_simple_normalize(self, state_data):
result = json_normalize(state_data[0], "counties")
expected = DataFrame(state_data[0]["counties"])
Expand Down Expand Up @@ -381,8 +377,6 @@ def test_meta_parameter_not_modified(self):
for val in ["metafoo", "metabar", "foo", "bar"]:
assert val in result

# TODO(ArrayManager) sanitize S/U numpy dtypes to object
@td.skip_array_manager_not_yet_implemented
def test_record_prefix(self, state_data):
result = json_normalize(state_data[0], "counties")
expected = DataFrame(state_data[0]["counties"])
Expand Down
1 change: 0 additions & 1 deletion pandas/tests/io/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ def test_write_fspath_all(self, writer_name, writer_kwargs, module):
@pytest.mark.filterwarnings( # pytables np.object usage
"ignore:`np.object` is a deprecated alias:DeprecationWarning"
)
@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) IO HDF5
def test_write_fspath_hdf5(self):
# Same test as write_fspath_all, except HDF5 files aren't
# necessarily byte-for-byte identical for a given dataframe, so we'll
Expand Down
9 changes: 4 additions & 5 deletions pandas/tests/io/test_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@
lzma = import_lzma()


# TODO(ArrayManager) pickling
pytestmark = [
td.skip_array_manager_not_yet_implemented,
pytest.mark.filterwarnings("ignore:Timestamp.freq is deprecated:FutureWarning"),
]
pytestmark = pytest.mark.filterwarnings(
"ignore:Timestamp.freq is deprecated:FutureWarning"
)


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -612,6 +610,7 @@ def test_pickle_strings(string_series):
tm.assert_series_equal(unp_series, string_series)


@td.skip_array_manager_invalid_test
def test_pickle_preserves_block_ndim():
# GH#37631
ser = Series(list("abc")).astype("category").iloc[[0]]
Expand Down
10 changes: 6 additions & 4 deletions pandas/tests/series/indexing/test_where.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,15 @@ def test_where_categorical(frame_or_series):
tm.assert_equal(exp, res)


# TODO(ArrayManager) DataFrame.values not yet correctly returning datetime array
# for categorical with datetime categories
@td.skip_array_manager_not_yet_implemented
def test_where_datetimelike_categorical(tz_naive_fixture):
def test_where_datetimelike_categorical(request, tz_naive_fixture, using_array_manager):
# GH#37682
tz = tz_naive_fixture

if using_array_manager and tz is None:
# TODO(ArrayManager) DataFrame.values not yet correctly returning datetime array
# for categorical with datetime categories
td.mark_array_manager_not_yet_implemented(request)

dr = date_range("2001-01-01", periods=3, tz=tz)._with_freq(None)
lvals = pd.DatetimeIndex([dr[0], dr[1], pd.NaT])
rvals = pd.Categorical([dr[0], pd.NaT, dr[2]])
Expand Down
3 changes: 0 additions & 3 deletions pandas/tests/test_downstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ def df():
return DataFrame({"A": [1, 2, 3]})


# TODO(ArrayManager) dask is still accessing the blocks
# https://github.com/dask/dask/pull/7318
@td.skip_array_manager_not_yet_implemented
@pytest.mark.filterwarnings("ignore:.*64Index is deprecated:FutureWarning")
def test_dask(df):

Expand Down
7 changes: 6 additions & 1 deletion pandas/util/_test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,12 @@ def async_mark():
return async_mark


skip_array_manager_not_yet_implemented = pytest.mark.skipif(
def mark_array_manager_not_yet_implemented(request):
mark = pytest.mark.xfail(reason="Not yet implemented for ArrayManager")
request.node.add_marker(mark)


skip_array_manager_not_yet_implemented = pytest.mark.xfail(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent! ive got a half-implemented branch doing the same thing!

get_option("mode.data_manager") == "array",
reason="Not yet implemented for ArrayManager",
)
Expand Down