Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
galipremsagar committed Sep 13, 2023
1 parent 833bfda commit bf33ebb
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions python/cudf/cudf/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -6362,6 +6362,7 @@ def test_df_series_dataframe_astype_dtype_dict(copy):
([range(100), range(100)], ["range" + str(i) for i in range(100)]),
(((1, 2, 3), (1, 2, 3)), ["tuple0", "tuple1", "tuple2"]),
([[1, 2, 3]], ["list col1", "list col2", "list col3"]),
([[1, 2, 3]], pd.Index(["col1", "col2", "col3"], name="rapids")),
([range(100)], ["range" + str(i) for i in range(100)]),
(((1, 2, 3),), ["k1", "k2", "k3"]),
],
Expand Down Expand Up @@ -7937,6 +7938,7 @@ def test_series_empty(ps):
@pytest.mark.parametrize(
"data",
[
None,
[],
[1],
{"a": [10, 11, 12]},
Expand All @@ -7947,7 +7949,10 @@ def test_series_empty(ps):
},
],
)
@pytest.mark.parametrize("columns", [["a"], ["another column name"], None])
@pytest.mark.parametrize(
"columns",
[["a"], ["another column name"], None, pd.Index(["a"], name="index name")],
)
def test_dataframe_init_with_columns(data, columns):
pdf = pd.DataFrame(data, columns=columns)
gdf = cudf.DataFrame(data, columns=columns)
Expand Down Expand Up @@ -8015,7 +8020,16 @@ def test_dataframe_init_with_columns(data, columns):
],
)
@pytest.mark.parametrize(
"columns", [None, ["0"], [0], ["abc"], [144, 13], [2, 1, 0]]
"columns",
[
None,
["0"],
[0],
["abc"],
[144, 13],
[2, 1, 0],
pd.Index(["abc"], name="custom_name"),
],
)
def test_dataframe_init_from_series_list(data, ignore_dtype, columns):
gd_data = [cudf.from_pandas(obj) for obj in data]
Expand Down Expand Up @@ -10207,7 +10221,14 @@ def test_dataframe_binop_with_datetime_index():


@pytest.mark.parametrize(
"columns", ([], ["c", "a"], ["a", "d", "b", "e", "c"], ["a", "b", "c"])
"columns",
(
[],
["c", "a"],
["a", "d", "b", "e", "c"],
["a", "b", "c"],
pd.Index(["b", "a"], name="custom_name"),
),
)
@pytest.mark.parametrize("index", (None, [4, 5, 6]))
def test_dataframe_dict_like_with_columns(columns, index):
Expand Down Expand Up @@ -10349,10 +10370,3 @@ def test_dataframe_round_builtin(digits):
actual = round(gdf, digits)

assert_eq(expected, actual)


def test_dataframe_empty_columns():
pdf = pd.DataFrame(columns=pd.Index(["a", "b", "c"], name="NAME"))
gdf = cudf.DataFrame(columns=pd.Index(["a", "b", "c"], name="NAME"))

assert_eq(pdf, gdf, check_index_type=False)

0 comments on commit bf33ebb

Please sign in to comment.