Skip to content

Commit 835c78e

Browse files
[ArrayManager] TST: Convert skip into xfail and clean-up tests that now work (#44571)
1 parent 5b108bc commit 835c78e

19 files changed

+55
-60
lines changed

pandas/tests/frame/indexing/test_setitem.py

-2
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,6 @@ def test_setitem_object_array_of_tzaware_datetimes(self, idx, expected):
728728

729729

730730
class TestDataFrameSetItemWithExpansion:
731-
# TODO(ArrayManager) update parent (_maybe_update_cacher)
732-
@td.skip_array_manager_not_yet_implemented
733731
def test_setitem_listlike_views(self):
734732
# GH#38148
735733
df = DataFrame({"a": [1, 2, 3], "b": [4, 4, 6]})

pandas/tests/frame/methods/test_fillna.py

-3
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ def test_fillna_categorical_nan(self):
232232
df = DataFrame({"a": Categorical(idx)})
233233
tm.assert_frame_equal(df.fillna(value=NaT), df)
234234

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

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

279-
@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) object upcasting
280277
@pytest.mark.parametrize("val", ["", 1, np.nan, 1.0])
281278
def test_fillna_dtype_conversion_equiv_replace(self, val):
282279
df = DataFrame({"A": [1, np.nan], "B": [1.0, 2.0]})

pandas/tests/frame/methods/test_interpolate.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,13 @@ def test_interp_string_axis(self, axis_name, axis_number):
328328
expected = df.interpolate(method="linear", axis=axis_number)
329329
tm.assert_frame_equal(result, expected)
330330

331-
@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) support axis=1
332331
@pytest.mark.parametrize("method", ["ffill", "bfill", "pad"])
333-
def test_interp_fillna_methods(self, axis, method):
332+
def test_interp_fillna_methods(self, request, axis, method, using_array_manager):
334333
# GH 12918
334+
if using_array_manager and (axis == 1 or axis == "columns"):
335+
# TODO(ArrayManager) support axis=1
336+
td.mark_array_manager_not_yet_implemented(request)
337+
335338
df = DataFrame(
336339
{
337340
"A": [1.0, 2.0, 3.0, 4.0, np.nan, 5.0],

pandas/tests/frame/methods/test_rename.py

-1
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ def test_rename_mapper_and_positional_arguments_raises(self):
365365
with pytest.raises(TypeError, match=msg):
366366
df.rename({}, columns={}, index={})
367367

368-
@td.skip_array_manager_not_yet_implemented
369368
def test_rename_with_duplicate_columns(self):
370369
# GH#4403
371370
df4 = DataFrame(

pandas/tests/frame/test_api.py

-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ def test_attrs(self):
296296
result = df.rename(columns=str)
297297
assert result.attrs == {"version": 1}
298298

299-
@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) setitem (no copy)
300299
@pytest.mark.parametrize("allows_duplicate_labels", [True, False, None])
301300
def test_set_flags(self, allows_duplicate_labels, frame_or_series):
302301
obj = DataFrame({"A": [1, 2]})

pandas/tests/frame/test_arithmetic.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -722,11 +722,16 @@ def test_df_add_2d_array_collike_broadcasts(self):
722722
result = collike + df
723723
tm.assert_frame_equal(result, expected)
724724

725-
@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) decide on dtypes
726-
def test_df_arith_2d_array_rowlike_broadcasts(self, all_arithmetic_operators):
725+
def test_df_arith_2d_array_rowlike_broadcasts(
726+
self, request, all_arithmetic_operators, using_array_manager
727+
):
727728
# GH#23000
728729
opname = all_arithmetic_operators
729730

731+
if using_array_manager and opname in ("__rmod__", "__rfloordiv__"):
732+
# TODO(ArrayManager) decide on dtypes
733+
td.mark_array_manager_not_yet_implemented(request)
734+
730735
arr = np.arange(6).reshape(3, 2)
731736
df = DataFrame(arr, columns=[True, False], index=["A", "B", "C"])
732737

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

747-
@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) decide on dtypes
748-
def test_df_arith_2d_array_collike_broadcasts(self, all_arithmetic_operators):
752+
def test_df_arith_2d_array_collike_broadcasts(
753+
self, request, all_arithmetic_operators, using_array_manager
754+
):
749755
# GH#23000
750756
opname = all_arithmetic_operators
751757

758+
if using_array_manager and opname in ("__rmod__", "__rfloordiv__"):
759+
# TODO(ArrayManager) decide on dtypes
760+
td.mark_array_manager_not_yet_implemented(request)
761+
752762
arr = np.arange(6).reshape(3, 2)
753763
df = DataFrame(arr, columns=[True, False], index=["A", "B", "C"])
754764

pandas/tests/frame/test_constructors.py

+19-5
Original file line numberDiff line numberDiff line change
@@ -2287,16 +2287,18 @@ def test_check_dtype_empty_numeric_column(self, dtype):
22872287

22882288
assert data.b.dtype == dtype
22892289

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

2298+
if using_array_manager and dtype in tm.BYTES_DTYPES:
2299+
# TODO(ArrayManager) astype to bytes dtypes does not yet give object dtype
2300+
td.mark_array_manager_not_yet_implemented(request)
2301+
23002302
assert data.b.dtype.name == "object"
23012303

23022304
def test_to_frame_with_falsey_names(self):
@@ -2466,8 +2468,20 @@ def test_constructor_list_str_na(self, string_dtype):
24662468
tm.assert_frame_equal(result, expected)
24672469

24682470
@pytest.mark.parametrize("copy", [False, True])
2469-
@td.skip_array_manager_not_yet_implemented
2470-
def test_dict_nocopy(self, copy, any_numeric_ea_dtype, any_numpy_dtype):
2471+
def test_dict_nocopy(
2472+
self, request, copy, any_numeric_ea_dtype, any_numpy_dtype, using_array_manager
2473+
):
2474+
if using_array_manager and not (
2475+
(any_numpy_dtype in (tm.STRING_DTYPES + tm.BYTES_DTYPES))
2476+
or (
2477+
any_numpy_dtype
2478+
in (tm.DATETIME64_DTYPES + tm.TIMEDELTA64_DTYPES + tm.BOOL_DTYPES)
2479+
and copy
2480+
)
2481+
):
2482+
# TODO(ArrayManager) properly honor copy keyword for dict input
2483+
td.mark_array_manager_not_yet_implemented(request)
2484+
24712485
a = np.array([1, 2], dtype=any_numpy_dtype)
24722486
b = np.array([3, 4], dtype=any_numpy_dtype)
24732487
if b.dtype.kind in ["S", "U"]:

pandas/tests/frame/test_stack_unstack.py

-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import numpy as np
66
import pytest
77

8-
import pandas.util._test_decorators as td
9-
108
import pandas as pd
119
from pandas import (
1210
DataFrame,
@@ -949,7 +947,6 @@ def test_unstack_nan_index4(self):
949947
left = df.loc[17264:].copy().set_index(["s_id", "dosage", "agent"])
950948
tm.assert_frame_equal(left.unstack(), right)
951949

952-
@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) MultiIndex bug
953950
def test_unstack_nan_index5(self):
954951
# GH9497 - multiple unstack with nulls
955952
df = DataFrame(

pandas/tests/groupby/aggregate/test_other.py

-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import numpy as np
99
import pytest
1010

11-
import pandas.util._test_decorators as td
12-
1311
import pandas as pd
1412
from pandas import (
1513
DataFrame,
@@ -424,7 +422,6 @@ def __call__(self, x):
424422
tm.assert_frame_equal(result, expected)
425423

426424

427-
@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) columns with ndarrays
428425
def test_agg_over_numpy_arrays():
429426
# GH 3788
430427
df = DataFrame(

pandas/tests/groupby/test_categorical.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import numpy as np
44
import pytest
55

6-
import pandas.util._test_decorators as td
7-
86
import pandas as pd
97
from pandas import (
108
Categorical,
@@ -301,9 +299,7 @@ def test_apply(ordered):
301299
tm.assert_series_equal(result, expected)
302300

303301

304-
# TODO(ArrayManager) incorrect dtype for mean()
305-
@td.skip_array_manager_not_yet_implemented
306-
def test_observed(observed, using_array_manager):
302+
def test_observed(observed):
307303
# multiple groupers, don't re-expand the output space
308304
# of the grouper
309305
# gh-14942 (implement)

pandas/tests/indexing/test_iloc.py

-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ def test_iloc_setitem_fullcol_categorical(self, indexer, key, using_array_manage
106106
expected = DataFrame({0: cat, 1: range(3)})
107107
tm.assert_frame_equal(df, expected)
108108

109-
# TODO(ArrayManager) does not yet update parent
110-
@td.skip_array_manager_not_yet_implemented
111109
@pytest.mark.parametrize("box", [array, Series])
112110
def test_iloc_setitem_ea_inplace(self, frame_or_series, box, using_array_manager):
113111
# GH#38952 Case with not setting a full column

pandas/tests/indexing/test_loc.py

-3
Original file line numberDiff line numberDiff line change
@@ -1143,9 +1143,6 @@ def test_loc_setitem_empty_append_single_value(self):
11431143
df.loc[0, "x"] = expected.loc[0, "x"]
11441144
tm.assert_frame_equal(df, expected)
11451145

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

pandas/tests/indexing/test_partial.py

-6
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
import numpy as np
88
import pytest
99

10-
import pandas.util._test_decorators as td
11-
1210
import pandas as pd
1311
from pandas import (
1412
DataFrame,
@@ -355,10 +353,6 @@ def test_partial_setting2(self):
355353
df.at[dates[-1] + dates.freq, 0] = 7
356354
tm.assert_frame_equal(df, expected)
357355

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

364358
# in a mixed dtype environment, try to preserve dtypes

pandas/tests/io/json/test_normalize.py

-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import numpy as np
44
import pytest
55

6-
import pandas.util._test_decorators as td
7-
86
from pandas import (
97
DataFrame,
108
Index,
@@ -153,8 +151,6 @@ def test_simple_records(self):
153151

154152
tm.assert_frame_equal(result, expected)
155153

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

384-
# TODO(ArrayManager) sanitize S/U numpy dtypes to object
385-
@td.skip_array_manager_not_yet_implemented
386380
def test_record_prefix(self, state_data):
387381
result = json_normalize(state_data[0], "counties")
388382
expected = DataFrame(state_data[0]["counties"])

pandas/tests/io/test_common.py

-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@ def test_write_fspath_all(self, writer_name, writer_kwargs, module):
384384
@pytest.mark.filterwarnings( # pytables np.object usage
385385
"ignore:`np.object` is a deprecated alias:DeprecationWarning"
386386
)
387-
@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) IO HDF5
388387
def test_write_fspath_hdf5(self):
389388
# Same test as write_fspath_all, except HDF5 files aren't
390389
# necessarily byte-for-byte identical for a given dataframe, so we'll

pandas/tests/io/test_pickle.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,9 @@
5454
lzma = import_lzma()
5555

5656

57-
# TODO(ArrayManager) pickling
58-
pytestmark = [
59-
td.skip_array_manager_not_yet_implemented,
60-
pytest.mark.filterwarnings("ignore:Timestamp.freq is deprecated:FutureWarning"),
61-
]
57+
pytestmark = pytest.mark.filterwarnings(
58+
"ignore:Timestamp.freq is deprecated:FutureWarning"
59+
)
6260

6361

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

614612

613+
@td.skip_array_manager_invalid_test
615614
def test_pickle_preserves_block_ndim():
616615
# GH#37631
617616
ser = Series(list("abc")).astype("category").iloc[[0]]

pandas/tests/series/indexing/test_where.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -440,13 +440,15 @@ def test_where_categorical(frame_or_series):
440440
tm.assert_equal(exp, res)
441441

442442

443-
# TODO(ArrayManager) DataFrame.values not yet correctly returning datetime array
444-
# for categorical with datetime categories
445-
@td.skip_array_manager_not_yet_implemented
446-
def test_where_datetimelike_categorical(tz_naive_fixture):
443+
def test_where_datetimelike_categorical(request, tz_naive_fixture, using_array_manager):
447444
# GH#37682
448445
tz = tz_naive_fixture
449446

447+
if using_array_manager and tz is None:
448+
# TODO(ArrayManager) DataFrame.values not yet correctly returning datetime array
449+
# for categorical with datetime categories
450+
td.mark_array_manager_not_yet_implemented(request)
451+
450452
dr = date_range("2001-01-01", periods=3, tz=tz)._with_freq(None)
451453
lvals = pd.DatetimeIndex([dr[0], dr[1], pd.NaT])
452454
rvals = pd.Categorical([dr[0], pd.NaT, dr[2]])

pandas/tests/test_downstream.py

-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ def df():
2929
return DataFrame({"A": [1, 2, 3]})
3030

3131

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

pandas/util/_test_decorators.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,12 @@ def async_mark():
285285
return async_mark
286286

287287

288-
skip_array_manager_not_yet_implemented = pytest.mark.skipif(
288+
def mark_array_manager_not_yet_implemented(request):
289+
mark = pytest.mark.xfail(reason="Not yet implemented for ArrayManager")
290+
request.node.add_marker(mark)
291+
292+
293+
skip_array_manager_not_yet_implemented = pytest.mark.xfail(
289294
get_option("mode.data_manager") == "array",
290295
reason="Not yet implemented for ArrayManager",
291296
)

0 commit comments

Comments
 (0)