Skip to content

Commit

Permalink
Avoid create GPU instances during test collection
Browse files Browse the repository at this point in the history
  • Loading branch information
er-eis committed May 3, 2024
1 parent 2124759 commit b5b9116
Showing 1 changed file with 46 additions and 24 deletions.
70 changes: 46 additions & 24 deletions python/cudf/cudf/tests/test_concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1880,27 +1880,27 @@ def test_concat_mixed_list_types_error(s1, s2):
@pytest.mark.parametrize(
"d",
[
{"first": cudf.DataFrame({"A": [1, 2], "B": [3, 4]})},
{"first": (cudf.DataFrame, {"data": {"A": [1, 2], "B": [3, 4]}})},
{
"first": cudf.DataFrame({"A": [1, 2], "B": [3, 4]}),
"second": cudf.DataFrame({"A": [5, 6], "B": [7, 8]}),
"third": cudf.DataFrame({"C": [1, 2, 3]}),
"first": (cudf.DataFrame, {"data": {"A": [1, 2], "B": [3, 4]}}),
"second": (cudf.DataFrame, {"data": {"A": [5, 6], "B": [7, 8]}}),
"third": (cudf.DataFrame, {"data": {"C": [1, 2, 3]}}),
},
{
"first": cudf.DataFrame({"A": [1, 2], "B": [3, 4]}),
"second": cudf.DataFrame({"C": [1, 2, 3]}),
"third": cudf.DataFrame({"A": [5, 6], "B": [7, 8]}),
"first": (cudf.DataFrame, {"data": {"A": [1, 2], "B": [3, 4]}}),
"second": (cudf.DataFrame, {"data": {"C": [1, 2, 3]}}),
"third": (cudf.DataFrame, {"data": {"A": [5, 6], "B": [7, 8]}}),
},
{
"first": cudf.DataFrame({"A": [1, 2], "B": [3, 4]}),
"second": cudf.DataFrame({"C": [1, 2, 3]}),
"third": cudf.DataFrame({"A": [5, 6], "C": [7, 8]}),
"fourth": cudf.DataFrame({"B": [9, 10]}),
"first": (cudf.DataFrame, {"data": {"A": [1, 2], "B": [3, 4]}}),
"second": (cudf.DataFrame, {"data": {"C": [1, 2, 3]}}),
"third": (cudf.DataFrame, {"data": {"A": [5, 6], "C": [7, 8]}}),
"fourth": (cudf.DataFrame, {"data": {"B": [9, 10]}}),
},
pytest.param(
{
"first": cudf.DataFrame({2.0: [1, 1]}),
"second": cudf.DataFrame({"test": ["abc", "def"]}),
"first": (cudf.DataFrame, {"data": {2.0: [1, 1]}}),
"second": (cudf.DataFrame, {"data": {"test": ["abc", "def"]}}),
},
marks=pytest.mark.xfail(
reason=(
Expand All @@ -1910,15 +1910,24 @@ def test_concat_mixed_list_types_error(s1, s2):
)
),
),
{"first": cudf.Series([1, 2, 3]), "second": cudf.Series([4, 5, 6])},
{
"first": cudf.DataFrame({"A": [1, 2], "B": [3, 4]}),
"second": cudf.Series([5, 6], name="C"),
"first": (cudf.Series, {"data": [1, 2, 3]}),
"second": (cudf.Series, {"data": [4, 5, 6]}),
},
{
"first": (cudf.DataFrame, {"data": {"A": [1, 2], "B": [3, 4]}}),
"second": (cudf.Series, {"data": [5, 6], "name": "C"}),
},
pytest.param(
{
"first": cudf.DataFrame({("A", "B"): [1, 2], "C": [3, 4]}),
"second": cudf.DataFrame({"D": [5, 6], ("A", "B"): [7, 8]}),
"first": (
cudf.DataFrame,
{"data": {("A", "B"): [1, 2], "C": [3, 4]}},
),
"second": (
cudf.DataFrame,
{"data": {"D": [5, 6], ("A", "B"): [7, 8]}},
),
},
marks=pytest.mark.xfail(
reason=(
Expand All @@ -1930,8 +1939,14 @@ def test_concat_mixed_list_types_error(s1, s2):
),
pytest.param(
{
"first": cudf.DataFrame({("A", "B"): [3, 4], 2.0: [1, 1]}),
"second": cudf.DataFrame({("C", "D"): [3, 4], 3.0: [5, 6]}),
"first": (
cudf.DataFrame,
{"data": {("A", "B"): [3, 4], 2.0: [1, 1]}},
),
"second": (
cudf.DataFrame,
{"data": {("C", "D"): [3, 4], 3.0: [5, 6]}},
),
},
marks=pytest.mark.xfail(
reason=(
Expand All @@ -1942,15 +1957,22 @@ def test_concat_mixed_list_types_error(s1, s2):
),
),
{
"first": cudf.DataFrame({(1, 2): [1, 2], (3, 4): [3, 4]}),
"second": cudf.DataFrame({(1, 2): [5, 6], (5, 6): [7, 8]}),
"first": (
cudf.DataFrame,
{"data": {(1, 2): [1, 2], (3, 4): [3, 4]}},
),
"second": (
cudf.DataFrame,
{"data": {(1, 2): [5, 6], (5, 6): [7, 8]}},
),
},
],
)
def test_concat_dictionary(d, axis):
result = cudf.concat(d, axis=axis)
_dict = {k: c(**v) for k, (c, v) in d.items()}
result = cudf.concat(_dict, axis=axis)
expected = cudf.from_pandas(
pd.concat({k: df.to_pandas() for k, df in d.items()}, axis=axis)
pd.concat({k: df.to_pandas() for k, df in _dict.items()}, axis=axis)
)
assert_eq(expected, result)

Expand Down

0 comments on commit b5b9116

Please sign in to comment.