diff --git a/python/cudf/cudf/tests/test_binops.py b/python/cudf/cudf/tests/test_binops.py index 0fbab146190..7d8c3b53115 100644 --- a/python/cudf/cudf/tests/test_binops.py +++ b/python/cudf/cudf/tests/test_binops.py @@ -318,7 +318,7 @@ def test_series_compare_nulls(cmpop, dtypes): expect[expect_mask] = cmpop(lser[expect_mask], rser[expect_mask]) got = cmpop(lser, rser) - utils.assert_eq(expect, got) + assert_eq(expect, got) @pytest.fixture @@ -349,7 +349,7 @@ def test_str_series_compare_str( Series.from_pandas(str_series_cmp_data), "a" ) - utils.assert_eq(expect, got.to_pandas(nullable=True)) + assert_eq(expect, got.to_pandas(nullable=True)) def test_str_series_compare_str_reflected( @@ -360,7 +360,7 @@ def test_str_series_compare_str_reflected( "a", Series.from_pandas(str_series_cmp_data) ) - utils.assert_eq(expect, got.to_pandas(nullable=True)) + assert_eq(expect, got.to_pandas(nullable=True)) def test_str_series_compare_num( @@ -371,7 +371,7 @@ def test_str_series_compare_num( Series.from_pandas(str_series_cmp_data), cmp_scalar ) - utils.assert_eq(expect, got.to_pandas(nullable=True)) + assert_eq(expect, got.to_pandas(nullable=True)) def test_str_series_compare_num_reflected( @@ -382,7 +382,7 @@ def test_str_series_compare_num_reflected( cmp_scalar, Series.from_pandas(str_series_cmp_data) ) - utils.assert_eq(expect, got.to_pandas(nullable=True)) + assert_eq(expect, got.to_pandas(nullable=True)) @pytest.mark.parametrize("obj_class", ["Series", "Index"]) @@ -612,12 +612,12 @@ def test_different_shapes_and_columns(binop): # Empty frame on the right side pd_frame = binop(pd.DataFrame({"x": [1, 2]}), pd.DataFrame({})) cd_frame = binop(cudf.DataFrame({"x": [1, 2]}), cudf.DataFrame({})) - utils.assert_eq(cd_frame, pd_frame) + assert_eq(cd_frame, pd_frame) # Empty frame on the left side pd_frame = pd.DataFrame({}) + pd.DataFrame({"x": [1, 2]}) cd_frame = cudf.DataFrame({}) + cudf.DataFrame({"x": [1, 2]}) - utils.assert_eq(cd_frame, pd_frame) + assert_eq(cd_frame, pd_frame) # Note: the below rely on a discrepancy between cudf and pandas # While pandas inserts columns in alphabetical order, cudf inserts in the @@ -627,12 +627,12 @@ def test_different_shapes_and_columns(binop): # More rows on the left side pd_frame = pd.DataFrame({"x": [1, 2, 3]}) + pd.DataFrame({"y": [1, 2]}) cd_frame = cudf.DataFrame({"x": [1, 2, 3]}) + cudf.DataFrame({"y": [1, 2]}) - utils.assert_eq(cd_frame, pd_frame) + assert_eq(cd_frame, pd_frame) # More rows on the right side pd_frame = pd.DataFrame({"x": [1, 2]}) + pd.DataFrame({"y": [1, 2, 3]}) cd_frame = cudf.DataFrame({"x": [1, 2]}) + cudf.DataFrame({"y": [1, 2, 3]}) - utils.assert_eq(cd_frame, pd_frame) + assert_eq(cd_frame, pd_frame) @pytest.mark.parametrize("binop", _binops) @@ -650,7 +650,7 @@ def test_different_shapes_and_same_columns(binop): ) # cast x as float64 so it matches pandas dtype cd_frame["x"] = cd_frame["x"].astype(np.float64) - utils.assert_eq(cd_frame, pd_frame) + assert_eq(cd_frame, pd_frame) @pytest.mark.parametrize("binop", _binops) @@ -680,7 +680,7 @@ def test_different_shapes_and_columns_with_unaligned_indices(binop): # cast x and y as float64 so it matches pandas dtype cd_frame["x"] = cd_frame["x"].astype(np.float64) cd_frame["y"] = cd_frame["y"].astype(np.float64) - utils.assert_eq(cd_frame, pd_frame) + assert_eq(cd_frame, pd_frame) pdf1 = pd.DataFrame({"x": [1, 1]}, index=["a", "a"]) pdf2 = pd.DataFrame({"x": [2]}, index=["a"]) @@ -688,7 +688,7 @@ def test_different_shapes_and_columns_with_unaligned_indices(binop): gdf2 = cudf.DataFrame.from_pandas(pdf2) pd_frame = binop(pdf1, pdf2) cd_frame = binop(gdf1, gdf2) - utils.assert_eq(pd_frame, cd_frame) + assert_eq(pd_frame, cd_frame) @pytest.mark.parametrize( @@ -717,12 +717,12 @@ def test_df_different_index_shape(df2, binop): def test_boolean_scalar_binop(op): psr = pd.Series(np.random.choice([True, False], 10)) gsr = cudf.from_pandas(psr) - utils.assert_eq(op(psr, True), op(gsr, True)) - utils.assert_eq(op(psr, False), op(gsr, False)) + assert_eq(op(psr, True), op(gsr, True)) + assert_eq(op(psr, False), op(gsr, False)) # cuDF scalar - utils.assert_eq(op(psr, True), op(gsr, cudf.Scalar(True))) - utils.assert_eq(op(psr, False), op(gsr, cudf.Scalar(False))) + assert_eq(op(psr, True), op(gsr, cudf.Scalar(True))) + assert_eq(op(psr, False), op(gsr, cudf.Scalar(False))) @pytest.mark.parametrize("func", _operators_arithmetic) @@ -747,7 +747,7 @@ def test_operator_func_between_series(dtype, func, has_nulls, fill_value): pdf_series_b, fill_value=fill_value ) - utils.assert_eq(pdf_result, gdf_result) + assert_eq(pdf_result, gdf_result) @pytest.mark.parametrize("func", _operators_arithmetic) @@ -773,7 +773,7 @@ def test_operator_func_series_and_scalar( scalar, fill_value=fill_value ) - utils.assert_eq(pdf_series_result, gdf_series_result) + assert_eq(pdf_series_result, gdf_series_result) _permu_values = [0, 1, None, np.nan] @@ -812,9 +812,9 @@ def test_operator_func_between_series_logical( and np.isnan(fill_value) ): with pytest.raises(AssertionError): - utils.assert_eq(expect, got) + assert_eq(expect, got) return - utils.assert_eq(expect, got) + assert_eq(expect, got) @pytest.mark.parametrize("dtype", ["float32", "float64"]) @@ -851,7 +851,7 @@ def test_operator_func_series_and_scalar_logical( expect = pdf_series_result got = gdf_series_result.to_pandas(nullable=True) - utils.assert_eq(expect, got) + assert_eq(expect, got) @pytest.mark.parametrize("func", _operators_arithmetic) @@ -887,7 +887,7 @@ def gen_df(): got = getattr(gdf1, func)(gdf2, fill_value=fill_value) expect = getattr(pdf1, func)(pdf2, fill_value=fill_value)[list(got._data)] - utils.assert_eq(expect, got) + assert_eq(expect, got) @pytest.mark.parametrize("func", _operators_comparison) @@ -923,7 +923,7 @@ def gen_df(): got = getattr(gdf1, func)(gdf2) expect = getattr(pdf1, func)(pdf2)[list(got._data)] - utils.assert_eq(expect, got) + assert_eq(expect, got) @pytest.mark.parametrize( @@ -949,7 +949,7 @@ def gen_df(): def test_binop_bool_uint(func, rhs): psr = pd.Series([True, False, False]) gsr = cudf.from_pandas(psr) - utils.assert_eq( + assert_eq( getattr(psr, func)(rhs), getattr(gsr, func)(rhs), check_dtype=False ) @@ -977,7 +977,7 @@ def test_floordiv_zero_float64(series_dtype, divisor_dtype, scalar_divisor): else: pd_div = pd.Series([0], dtype=divisor_dtype) cudf_div = cudf.from_pandas(pd_div) - utils.assert_eq(sr // pd_div, cr // cudf_div) + assert_eq(sr // pd_div, cr // cudf_div) @pytest.mark.parametrize("scalar_divisor", [False, True]) @@ -1023,27 +1023,27 @@ def test_floordiv_zero_bool(scalar_divisor): def test_rmod_zero_nan(dtype): sr = pd.Series([1, 1, 0], dtype=dtype) cr = cudf.from_pandas(sr) - utils.assert_eq(1 % sr, 1 % cr) + assert_eq(1 % sr, 1 % cr) expected_dtype = np.float64 if cr.dtype.kind != "f" else dtype - utils.assert_eq(1 % cr, cudf.Series([0, 0, None], dtype=expected_dtype)) + assert_eq(1 % cr, cudf.Series([0, 0, None], dtype=expected_dtype)) def test_series_misc_binop(): pds = pd.Series([1, 2, 4], name="abc xyz") gds = cudf.Series([1, 2, 4], name="abc xyz") - utils.assert_eq(pds + 1, gds + 1) - utils.assert_eq(1 + pds, 1 + gds) + assert_eq(pds + 1, gds + 1) + assert_eq(1 + pds, 1 + gds) - utils.assert_eq(pds + pds, gds + gds) + assert_eq(pds + pds, gds + gds) pds1 = pd.Series([1, 2, 4], name="hello world") gds1 = cudf.Series([1, 2, 4], name="hello world") - utils.assert_eq(pds + pds1, gds + gds1) - utils.assert_eq(pds1 + pds, gds1 + gds) + assert_eq(pds + pds1, gds + gds1) + assert_eq(pds1 + pds, gds1 + gds) - utils.assert_eq(pds1 + pds + 5, gds1 + gds + 5) + assert_eq(pds1 + pds + 5, gds1 + gds + 5) def test_int8_float16_binop(): @@ -1051,7 +1051,7 @@ def test_int8_float16_binop(): b = np.float16(2) expect = cudf.Series([0.5]) got = a / b - utils.assert_eq(expect, got, check_dtype=False) + assert_eq(expect, got, check_dtype=False) @pytest.mark.parametrize("dtype", ["int64", "float64", "str"]) @@ -1061,7 +1061,7 @@ def test_vector_to_none_binops(dtype): expect = Series([None] * 4).astype(dtype) got = data + None - utils.assert_eq(expect, got) + assert_eq(expect, got) def dtype_scalar(val, dtype): @@ -1747,12 +1747,12 @@ def test_datetime_dateoffset_binaryop( expect = op(psr, poffset) got = op(gsr, goffset) - utils.assert_eq(expect, got) + assert_eq(expect, got) expect = op(psr, -poffset) got = op(gsr, -goffset) - utils.assert_eq(expect, got) + assert_eq(expect, got) @pytest.mark.parametrize( @@ -1793,7 +1793,7 @@ def test_datetime_dateoffset_binaryop_multiple(date_col, kwargs, op): expect = op(psr, poffset) got = op(gsr, goffset) - utils.assert_eq(expect, got) + assert_eq(expect, got) @pytest.mark.parametrize("n_periods", [0, 1, -1, 12, -12]) @@ -1840,7 +1840,7 @@ def test_datetime_dateoffset_binaryop_reflected( # TODO: Remove check_dtype once we get some clarity on: # https://github.com/pandas-dev/pandas/issues/57448 - utils.assert_eq(expect, got, check_dtype=False) + assert_eq(expect, got, check_dtype=False) with pytest.raises(TypeError): poffset - psr @@ -1878,7 +1878,7 @@ def test_binops_with_lhs_numpy_scalar(frame, dtype): expected = data.to_pandas() == val got = data == val - utils.assert_eq(expected, got) + assert_eq(expected, got) @pytest.mark.parametrize( @@ -2302,7 +2302,7 @@ def test_binops_decimal(op, lhs, l_dtype, rhs, r_dtype, expect, expect_dtype): got = op(a, b) assert expect.dtype == got.dtype - utils.assert_eq(expect, got) + assert_eq(expect, got) @pytest.mark.parametrize( @@ -2355,7 +2355,7 @@ def test_binops_reflect_decimal( got = getattr(a, op)(b) assert expect.dtype == got.dtype - utils.assert_eq(expect, got) + assert_eq(expect, got) @pytest.mark.parametrize("powers", [0, 1, 2, 3]) @@ -2371,7 +2371,7 @@ def test_binops_decimal_pow(powers): ) ps = s.to_pandas() - utils.assert_eq(s**powers, ps**powers, check_dtype=False) + assert_eq(s**powers, ps**powers, check_dtype=False) def test_binops_raise_error(): @@ -2554,7 +2554,7 @@ def test_binops_decimal_comp_mixed_integer(args, integer_dtype, reflected): actual = op(lhs, rhs) - utils.assert_eq(expected, actual) + assert_eq(expected, actual) @pytest.mark.parametrize( @@ -2804,7 +2804,7 @@ def decimal_series(input, dtype): got = op(lhs, rhs) assert expect.dtype == got.dtype - utils.assert_eq(expect, got) + assert_eq(expect, got) @pytest.mark.parametrize( @@ -2979,7 +2979,7 @@ def test_binops_decimal_scalar_compare(args, reflected): actual = op(lhs, rhs) - utils.assert_eq(expected, actual) + assert_eq(expected, actual) @pytest.mark.parametrize( @@ -3042,7 +3042,7 @@ def test_equality_ops_index_mismatch(fn): expected = getattr(pa, fn)(pb) actual = getattr(a, fn)(b).to_pandas(nullable=True) - utils.assert_eq(expected, actual) + assert_eq(expected, actual) def generate_test_null_equals_columnops_data(): @@ -3132,7 +3132,7 @@ def test_empty_column(binop, data, scalar): got = binop(gdf, scalar) expected = binop(pdf, scalar) - utils.assert_eq(expected, got) + assert_eq(expected, got) @pytest.mark.parametrize( @@ -3179,7 +3179,7 @@ def test_binops_dot(df, other): expected = pdf @ host_other got = df @ other - utils.assert_eq(expected, got) + assert_eq(expected, got) def test_binop_dot_preserve_index(): @@ -3187,7 +3187,7 @@ def test_binop_dot_preserve_index(): df = cudf.DataFrame(np.eye(2), columns=["A", "B"], index=["A", "B"]) result = ser @ df expected = ser.to_pandas() @ df.to_pandas() - utils.assert_eq(result, expected) + assert_eq(result, expected) def test_binop_series_with_repeated_index(): @@ -3198,7 +3198,7 @@ def test_binop_series_with_repeated_index(): gsr2 = cudf.from_pandas(psr2) expected = psr1 - psr2 got = gsr1 - gsr2 - utils.assert_eq(expected, got) + assert_eq(expected, got) def test_binop_integer_power_series_series(): @@ -3209,7 +3209,7 @@ def test_binop_integer_power_series_series(): ps_exponent = gs_exponent.to_pandas() expected = ps_base**ps_exponent got = gs_base**gs_exponent - utils.assert_eq(expected, got) + assert_eq(expected, got) def test_binop_integer_power_series_scalar(): @@ -3219,7 +3219,7 @@ def test_binop_integer_power_series_scalar(): ps_base = gs_base.to_pandas() expected = ps_base**exponent.value got = gs_base**exponent - utils.assert_eq(expected, got) + assert_eq(expected, got) def test_binop_integer_power_series_int(): @@ -3229,7 +3229,7 @@ def test_binop_integer_power_series_int(): ps_base = gs_base.to_pandas() expected = ps_base**exponent got = gs_base**exponent - utils.assert_eq(expected, got) + assert_eq(expected, got) def test_binop_integer_power_scalar_series(): @@ -3239,7 +3239,7 @@ def test_binop_integer_power_scalar_series(): ps_exponent = gs_exponent.to_pandas() expected = base.value**ps_exponent got = base**gs_exponent - utils.assert_eq(expected, got) + assert_eq(expected, got) def test_binop_integer_power_scalar_scalar(): @@ -3248,7 +3248,7 @@ def test_binop_integer_power_scalar_scalar(): exponent = cudf.Scalar(1) expected = base.value**exponent.value got = base**exponent - utils.assert_eq(expected, got) + assert_eq(expected, got) def test_binop_integer_power_scalar_int(): @@ -3257,7 +3257,7 @@ def test_binop_integer_power_scalar_int(): exponent = 1 expected = base.value**exponent got = base**exponent - utils.assert_eq(expected, got) + assert_eq(expected, got) def test_binop_integer_power_int_series(): @@ -3267,7 +3267,7 @@ def test_binop_integer_power_int_series(): ps_exponent = gs_exponent.to_pandas() expected = base**ps_exponent got = base**gs_exponent - utils.assert_eq(expected, got) + assert_eq(expected, got) def test_binop_integer_power_int_scalar(): @@ -3276,7 +3276,7 @@ def test_binop_integer_power_int_scalar(): exponent = cudf.Scalar(1) expected = base**exponent.value got = base**exponent - utils.assert_eq(expected, got) + assert_eq(expected, got) def test_numpy_int_scalar_binop(): @@ -3291,7 +3291,7 @@ def test_binop_index_series(op): actual = op(gi, gs) expected = op(gi.to_pandas(), gs.to_pandas()) - utils.assert_eq(expected, actual) + assert_eq(expected, actual) @pytest.mark.parametrize("name1", utils.SERIES_OR_INDEX_NAMES) @@ -3307,7 +3307,7 @@ def test_binop_index_dt_td_series_with_names(name1, name2): expected = gi.to_pandas() + gs.to_pandas() actual = gi + gs - utils.assert_eq(expected, actual) + assert_eq(expected, actual) @pytest.mark.parametrize("data1", [[1, 2, 3], [10, 11, None]]) @@ -3319,9 +3319,9 @@ def test_binop_eq_ne_index_series(data1, data2): actual = gi == gs expected = gi.to_pandas() == gs.to_pandas() - utils.assert_eq(expected, actual) + assert_eq(expected, actual) actual = gi != gs expected = gi.to_pandas() != gs.to_pandas() - utils.assert_eq(expected, actual) + assert_eq(expected, actual) diff --git a/python/cudf/cudf/tests/test_unaops.py b/python/cudf/cudf/tests/test_unaops.py index 15d9d03d4a7..dbbf4fba3a6 100644 --- a/python/cudf/cudf/tests/test_unaops.py +++ b/python/cudf/cudf/tests/test_unaops.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019-2023, NVIDIA CORPORATION. +# Copyright (c) 2019-2024, NVIDIA CORPORATION. import itertools import operator @@ -10,7 +10,7 @@ import cudf from cudf import Series -from cudf.testing import _utils as utils +from cudf.testing import _utils as utils, assert_eq _unaops = [operator.abs, operator.invert, operator.neg, np.ceil, np.floor] @@ -128,4 +128,4 @@ def test_scalar_no_negative_bools(): def test_series_bool_neg(): sr = Series([True, False, True, None, False, None, True, True]) psr = sr.to_pandas(nullable=True) - utils.assert_eq((-sr).to_pandas(nullable=True), -psr, check_dtype=True) + assert_eq((-sr).to_pandas(nullable=True), -psr, check_dtype=True) diff --git a/python/custreamz/custreamz/tests/test_kafka.py b/python/custreamz/custreamz/tests/test_kafka.py index ad3b829544b..3a3c4e994d0 100644 --- a/python/custreamz/custreamz/tests/test_kafka.py +++ b/python/custreamz/custreamz/tests/test_kafka.py @@ -1,8 +1,8 @@ -# Copyright (c) 2020, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. import confluent_kafka as ck import pytest -from cudf.testing._utils import assert_eq +from cudf.testing import assert_eq @pytest.mark.parametrize("commit_offset", [1, 45, 100, 22, 1000, 10]) diff --git a/python/dask_cudf/dask_cudf/tests/test_accessor.py b/python/dask_cudf/dask_cudf/tests/test_accessor.py index 58d28f0597e..6f04b5737da 100644 --- a/python/dask_cudf/dask_cudf/tests/test_accessor.py +++ b/python/dask_cudf/dask_cudf/tests/test_accessor.py @@ -9,7 +9,8 @@ from dask import dataframe as dd from cudf import DataFrame, Series, date_range -from cudf.testing._utils import assert_eq, does_not_raise +from cudf.testing import assert_eq +from cudf.testing._utils import does_not_raise import dask_cudf from dask_cudf.tests.utils import xfail_dask_expr diff --git a/python/dask_cudf/dask_cudf/tests/test_distributed.py b/python/dask_cudf/dask_cudf/tests/test_distributed.py index 07fdb25dff9..be10b0d4843 100644 --- a/python/dask_cudf/dask_cudf/tests/test_distributed.py +++ b/python/dask_cudf/dask_cudf/tests/test_distributed.py @@ -9,7 +9,7 @@ from distributed.utils_test import cleanup, loop, loop_in_thread # noqa: F401 import cudf -from cudf.testing._utils import assert_eq +from cudf.testing import assert_eq import dask_cudf