From d4a07e79f83301698a8cb82cedeeb89a54940685 Mon Sep 17 00:00:00 2001 From: Thomas Li Date: Thu, 30 May 2024 10:18:04 -0700 Subject: [PATCH 1/2] Clean up pylibcudf test assertations --- python/cudf/cudf/pylibcudf_tests/common/utils.py | 2 +- python/cudf/cudf/pylibcudf_tests/test_reshape.py | 4 ++-- python/cudf/cudf/pylibcudf_tests/test_string_capitalize.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python/cudf/cudf/pylibcudf_tests/common/utils.py b/python/cudf/cudf/pylibcudf_tests/common/utils.py index 0befb3bb3e8..e00053529a8 100644 --- a/python/cudf/cudf/pylibcudf_tests/common/utils.py +++ b/python/cudf/cudf/pylibcudf_tests/common/utils.py @@ -54,7 +54,7 @@ def assert_column_eq( assert lhs.equals(rhs) -def assert_table_eq(plc_table: plc.Table, pa_table: pa.Table) -> None: +def assert_table_eq(pa_table: pa.Table, plc_table: plc.Table) -> None: """Verify that a pylibcudf table and PyArrow table are equal.""" plc_shape = (plc_table.num_rows(), plc_table.num_columns()) assert plc_shape == pa_table.shape diff --git a/python/cudf/cudf/pylibcudf_tests/test_reshape.py b/python/cudf/cudf/pylibcudf_tests/test_reshape.py index b8b914f3f09..32d79257f4f 100644 --- a/python/cudf/cudf/pylibcudf_tests/test_reshape.py +++ b/python/cudf/cudf/pylibcudf_tests/test_reshape.py @@ -27,7 +27,7 @@ def test_interleave_columns(reshape_data, reshape_plc_tbl): expect = pa.concat_arrays(interleaved_data) - assert_column_eq(res, expect) + assert_column_eq(expect, res) @pytest.mark.parametrize("cnt", [0, 1, 3]) @@ -40,4 +40,4 @@ def test_tile(reshape_data, reshape_plc_tbl, cnt): tiled_data, schema=plc.interop.to_arrow(reshape_plc_tbl).schema ) - assert_table_eq(res, expect) + assert_table_eq(expect, res) diff --git a/python/cudf/cudf/pylibcudf_tests/test_string_capitalize.py b/python/cudf/cudf/pylibcudf_tests/test_string_capitalize.py index dd7e96e871b..818d6e6e72a 100644 --- a/python/cudf/cudf/pylibcudf_tests/test_string_capitalize.py +++ b/python/cudf/cudf/pylibcudf_tests/test_string_capitalize.py @@ -37,7 +37,7 @@ def plc_data(pa_data): def test_capitalize(plc_data, pa_data): got = plc.strings.capitalize.capitalize(plc_data) expected = pa.compute.utf8_capitalize(pa_data) - assert_column_eq(got, expected) + assert_column_eq(expected, got) def test_title(plc_data, pa_data): @@ -45,10 +45,10 @@ def test_title(plc_data, pa_data): plc_data, plc.strings.char_types.StringCharacterTypes.CASE_TYPES ) expected = pa.compute.utf8_title(pa_data) - assert_column_eq(got, expected) + assert_column_eq(expected, got) def test_is_title(plc_data, pa_data): got = plc.strings.capitalize.is_title(plc_data) expected = pa.compute.utf8_is_title(pa_data) - assert_column_eq(got, expected) + assert_column_eq(expected, got) From 3addd7e2cd1f7886fa79081e97a1f4221aa7d3db Mon Sep 17 00:00:00 2001 From: Thomas Li <47963215+lithomas1@users.noreply.github.com> Date: Thu, 30 May 2024 11:08:17 -0700 Subject: [PATCH 2/2] Update test_copying.py --- python/cudf/cudf/pylibcudf_tests/test_copying.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/python/cudf/cudf/pylibcudf_tests/test_copying.py b/python/cudf/cudf/pylibcudf_tests/test_copying.py index ef70869a145..cd70ce4abf5 100644 --- a/python/cudf/cudf/pylibcudf_tests/test_copying.py +++ b/python/cudf/cudf/pylibcudf_tests/test_copying.py @@ -138,7 +138,7 @@ def test_gather(target_table, pa_target_table, index_column, pa_index_column): plc.copying.OutOfBoundsPolicy.DONT_CHECK, ) expected = pa_target_table.take(pa_index_column) - assert_table_eq(result, expected) + assert_table_eq(expected, result) def test_gather_map_has_nulls(target_table): @@ -240,7 +240,7 @@ def test_scatter_table( pa_target_table, ) - assert_table_eq(result, expected) + assert_table_eq(expected, result) def test_scatter_table_num_col_mismatch( @@ -315,7 +315,7 @@ def test_scatter_scalars( pa_target_table, ) - assert_table_eq(result, expected) + assert_table_eq(expected, result) def test_scatter_scalars_num_scalars_mismatch( @@ -574,7 +574,7 @@ def test_slice_table(target_table, pa_target_table): lower_bounds = bounds[::2] result = plc.copying.slice(target_table, bounds) for lb, ub, slice_ in zip(lower_bounds, upper_bounds, result): - assert_table_eq(slice_, pa_target_table[lb:ub]) + assert_table_eq(pa_target_table[lb:ub], slice_) def test_split_column(target_column, pa_target_column): @@ -600,7 +600,7 @@ def test_split_table(target_table, pa_target_table): lower_bounds = [0] + upper_bounds[:-1] result = plc.copying.split(target_table, upper_bounds) for lb, ub, split in zip(lower_bounds, upper_bounds, result): - assert_table_eq(split, pa_target_table[lb:ub]) + assert_table_eq(pa_target_table[lb:ub], split) def test_copy_if_else_column_column( @@ -753,7 +753,7 @@ def test_boolean_mask_scatter_from_table( pa_source_table, pa_mask, pa_target_table ) - assert_table_eq(result, expected) + assert_table_eq(expected, result) def test_boolean_mask_scatter_from_wrong_num_cols(source_table, target_table): @@ -828,7 +828,7 @@ def test_boolean_mask_scatter_from_scalars( pa_target_table, ) - assert_table_eq(result, expected) + assert_table_eq(expected, result) def test_get_element(input_column, pa_input_column):