Skip to content

Commit c5695c8

Browse files
[ArrayManager] TST: get tests running for /tests/frame (#39700)
1 parent 7f2fc6a commit c5695c8

File tree

7 files changed

+45
-12
lines changed

7 files changed

+45
-12
lines changed

.github/workflows/ci.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ jobs:
154154
PANDAS_DATA_MANAGER: array
155155
run: |
156156
source activate pandas-dev
157+
157158
pytest pandas/tests/frame/methods
158159
pytest pandas/tests/frame/test_constructors.py
159-
pytest pandas/tests/frame/constructors/
160+
pytest pandas/tests/frame/test_*
160161
pytest pandas/tests/frame/test_reductions.py
161162
pytest pandas/tests/reductions/
162163
pytest pandas/tests/generic/test_generic.py

pandas/tests/frame/test_api.py

+1
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ 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)
299300
@pytest.mark.parametrize("allows_duplicate_labels", [True, False, None])
300301
def test_set_flags(self, allows_duplicate_labels, frame_or_series):
301302
obj = DataFrame({"A": [1, 2]})

pandas/tests/frame/test_arithmetic.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import pytest
88
import pytz
99

10+
import pandas.util._test_decorators as td
11+
1012
import pandas as pd
1113
from pandas import (
1214
DataFrame,
@@ -686,6 +688,7 @@ def test_df_add_2d_array_collike_broadcasts(self):
686688
result = collike + df
687689
tm.assert_frame_equal(result, expected)
688690

691+
@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) decide on dtypes
689692
def test_df_arith_2d_array_rowlike_broadcasts(self, all_arithmetic_operators):
690693
# GH#23000
691694
opname = all_arithmetic_operators
@@ -707,6 +710,7 @@ def test_df_arith_2d_array_rowlike_broadcasts(self, all_arithmetic_operators):
707710
result = getattr(df, opname)(rowlike)
708711
tm.assert_frame_equal(result, expected)
709712

713+
@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) decide on dtypes
710714
def test_df_arith_2d_array_collike_broadcasts(self, all_arithmetic_operators):
711715
# GH#23000
712716
opname = all_arithmetic_operators
@@ -1351,7 +1355,7 @@ def test_strings_to_numbers_comparisons_raises(self, compare_operators_no_eq_ne)
13511355

13521356
def test_comparison_protected_from_errstate(self):
13531357
missing_df = tm.makeDataFrame()
1354-
missing_df.iloc[0]["A"] = np.nan
1358+
missing_df.loc[missing_df.index[0], "A"] = np.nan
13551359
with np.errstate(invalid="ignore"):
13561360
expected = missing_df.values < 0
13571361
with np.errstate(invalid="raise"):

pandas/tests/frame/test_block_internals.py

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import pytest
1010

1111
from pandas.errors import PerformanceWarning
12+
import pandas.util._test_decorators as td
1213

1314
import pandas as pd
1415
from pandas import (
@@ -30,6 +31,11 @@
3031
# structure
3132

3233

34+
# TODO(ArrayManager) check which of those tests need to be rewritten to test the
35+
# equivalent for ArrayManager
36+
pytestmark = td.skip_array_manager_invalid_test
37+
38+
3339
class TestDataFrameBlockInternals:
3440
def test_setitem_invalidates_datetime_index_freq(self):
3541
# GH#24096 altering a datetime64tz column inplace invalidates the

pandas/tests/frame/test_nonunique_indexes.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def test_multi_dtype2(self):
291291
expected = DataFrame([[1, 2, "foo", "bar"]], columns=["a", "a.1", "a.2", "a.3"])
292292
tm.assert_frame_equal(df, expected)
293293

294-
def test_dups_across_blocks(self):
294+
def test_dups_across_blocks(self, using_array_manager):
295295
# dups across blocks
296296
df_float = DataFrame(np.random.randn(10, 3), dtype="float64")
297297
df_int = DataFrame(np.random.randn(10, 3), dtype="int64")
@@ -302,8 +302,9 @@ def test_dups_across_blocks(self):
302302
)
303303
df = pd.concat([df_float, df_int, df_bool, df_object, df_dt], axis=1)
304304

305-
assert len(df._mgr.blknos) == len(df.columns)
306-
assert len(df._mgr.blklocs) == len(df.columns)
305+
if not using_array_manager:
306+
assert len(df._mgr.blknos) == len(df.columns)
307+
assert len(df._mgr.blklocs) == len(df.columns)
307308

308309
# testing iloc
309310
for i in range(len(df.columns)):

pandas/tests/frame/test_repr_info.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@
2626

2727

2828
class TestDataFrameReprInfoEtc:
29-
def test_repr_bytes_61_lines(self):
29+
def test_repr_bytes_61_lines(self, using_array_manager):
3030
# GH#12857
3131
lets = list("ACDEFGHIJKLMNOP")
3232
slen = 50
3333
nseqs = 1000
3434
words = [[np.random.choice(lets) for x in range(slen)] for _ in range(nseqs)]
3535
df = DataFrame(words).astype("U1")
36-
assert (df.dtypes == object).all()
36+
# TODO(Arraymanager) astype("U1") actually gives this dtype instead of object
37+
if not using_array_manager:
38+
assert (df.dtypes == object).all()
3739

3840
# smoke tests; at one point this raised with 61 but not 60
3941
repr(df)

pandas/tests/frame/test_stack_unstack.py

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

8+
import pandas.util._test_decorators as td
9+
810
import pandas as pd
911
from pandas import (
1012
DataFrame,
@@ -60,12 +62,13 @@ def test_stack_mixed_level(self):
6062
expected = expected[["a", "b"]]
6163
tm.assert_frame_equal(result, expected)
6264

63-
def test_unstack_not_consolidated(self):
65+
def test_unstack_not_consolidated(self, using_array_manager):
6466
# Gh#34708
6567
df = DataFrame({"x": [1, 2, np.NaN], "y": [3.0, 4, np.NaN]})
6668
df2 = df[["x"]]
6769
df2["y"] = df["y"]
68-
assert len(df2._mgr.blocks) == 2
70+
if not using_array_manager:
71+
assert len(df2._mgr.blocks) == 2
6972

7073
res = df2.unstack()
7174
expected = df.unstack()
@@ -747,7 +750,8 @@ def test_unstack_multi_level_rows_and_cols(self):
747750
expected = df.unstack(["i3"]).unstack(["i2"])
748751
tm.assert_frame_equal(result, expected)
749752

750-
def test_unstack_nan_index(self): # GH7466
753+
def test_unstack_nan_index1(self):
754+
# GH7466
751755
def cast(val):
752756
val_str = "" if val != val else val
753757
return f"{val_str:1}"
@@ -833,6 +837,7 @@ def verify(df):
833837
for col in ["4th", "5th"]:
834838
verify(udf[col])
835839

840+
def test_unstack_nan_index2(self):
836841
# GH7403
837842
df = DataFrame({"A": list("aaaabbbb"), "B": range(8), "C": range(8)})
838843
df.iloc[3, 1] = np.NaN
@@ -875,6 +880,7 @@ def verify(df):
875880
right = DataFrame(vals, columns=cols, index=idx)
876881
tm.assert_frame_equal(left, right)
877882

883+
def test_unstack_nan_index3(self, using_array_manager):
878884
# GH7401
879885
df = DataFrame(
880886
{
@@ -896,8 +902,13 @@ def verify(df):
896902
)
897903

898904
right = DataFrame(vals, columns=cols, index=idx)
905+
if using_array_manager:
906+
# INFO(ArrayManager) with ArrayManager preserve dtype where possible
907+
cols = right.columns[[1, 2, 3, 5]]
908+
right[cols] = right[cols].astype("int64")
899909
tm.assert_frame_equal(left, right)
900910

911+
def test_unstack_nan_index4(self):
901912
# GH4862
902913
vals = [
903914
["Hg", np.nan, np.nan, 680585148],
@@ -938,6 +949,8 @@ def verify(df):
938949
left = df.loc[17264:].copy().set_index(["s_id", "dosage", "agent"])
939950
tm.assert_frame_equal(left.unstack(), right)
940951

952+
@td.skip_array_manager_not_yet_implemented # TODO(ArrayManager) MultiIndex bug
953+
def test_unstack_nan_index5(self):
941954
# GH9497 - multiple unstack with nulls
942955
df = DataFrame(
943956
{
@@ -1887,7 +1900,7 @@ def test_unstack_group_index_overflow(self):
18871900
result = s.unstack(4)
18881901
assert result.shape == (500, 2)
18891902

1890-
def test_unstack_with_missing_int_cast_to_float(self):
1903+
def test_unstack_with_missing_int_cast_to_float(self, using_array_manager):
18911904
# https://github.com/pandas-dev/pandas/issues/37115
18921905
df = DataFrame(
18931906
{
@@ -1899,7 +1912,8 @@ def test_unstack_with_missing_int_cast_to_float(self):
18991912

19001913
# add another int column to get 2 blocks
19011914
df["is_"] = 1
1902-
assert len(df._mgr.blocks) == 2
1915+
if not using_array_manager:
1916+
assert len(df._mgr.blocks) == 2
19031917

19041918
result = df.unstack("b")
19051919
result[("is_", "ca")] = result[("is_", "ca")].fillna(0)
@@ -1912,6 +1926,10 @@ def test_unstack_with_missing_int_cast_to_float(self):
19121926
names=[None, "b"],
19131927
),
19141928
)
1929+
if using_array_manager:
1930+
# INFO(ArrayManager) with ArrayManager preserve dtype where possible
1931+
expected[("v", "cb")] = expected[("v", "cb")].astype("int64")
1932+
expected[("is_", "cb")] = expected[("is_", "cb")].astype("int64")
19151933
tm.assert_frame_equal(result, expected)
19161934

19171935
def test_unstack_with_level_has_nan(self):

0 commit comments

Comments
 (0)