Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce number of tests marked spilling #12197

Merged
merged 2 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
253 changes: 134 additions & 119 deletions python/cudf/cudf/tests/test_binops.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import cudf
from cudf import Series
from cudf.core._compat import PANDAS_GE_150
from cudf.core.buffer.spill_manager import get_global_manager
from cudf.core.index import as_index
from cudf.testing import _utils as utils
from cudf.utils.dtypes import (
Expand All @@ -27,7 +28,6 @@

STRING_TYPES = {"str"}


_binops = [
operator.add,
operator.sub,
Expand All @@ -47,8 +47,131 @@
operator.ge,
]

_bitwise_binops = [operator.and_, operator.or_, operator.xor]

_int_types = [
"int8",
"int16",
"int32",
"int64",
"uint8",
"uint16",
"uint32",
]

_cmpops = [
operator.lt,
operator.gt,
operator.le,
operator.ge,
operator.eq,
operator.ne,
]

_reflected_ops = [
lambda x: 1 + x,
lambda x: 2 * x,
lambda x: 2 - x,
lambda x: 2 // x,
lambda x: 2 / x,
lambda x: 3 + x,
lambda x: 3 * x,
lambda x: 3 - x,
lambda x: 3 // x,
lambda x: 3 / x,
lambda x: 3 % x,
lambda x: -1 + x,
lambda x: -2 * x,
lambda x: -2 - x,
lambda x: -2 // x,
lambda x: -2 / x,
lambda x: -3 + x,
lambda x: -3 * x,
lambda x: -3 - x,
lambda x: -3 // x,
lambda x: -3 / x,
lambda x: -3 % x,
lambda x: 0 + x,
lambda x: 0 * x,
lambda x: 0 - x,
lambda x: 0 // x,
lambda x: 0 / x,
]

_operators_arithmetic = [
"add",
"radd",
"sub",
"rsub",
"mul",
"rmul",
"mod",
"rmod",
"pow",
"rpow",
"div",
"divide",
"floordiv",
"rfloordiv",
"truediv",
"rtruediv",
]

_operators_comparison = ["eq", "ne", "lt", "le", "gt", "ge"]


_cudf_scalar_reflected_ops = [
lambda x: cudf.Scalar(1) + x,
lambda x: cudf.Scalar(2) * x,
lambda x: cudf.Scalar(2) - x,
lambda x: cudf.Scalar(2) // x,
lambda x: cudf.Scalar(2) / x,
lambda x: cudf.Scalar(3) + x,
lambda x: cudf.Scalar(3) * x,
lambda x: cudf.Scalar(3) - x,
lambda x: cudf.Scalar(3) // x,
lambda x: cudf.Scalar(3) / x,
lambda x: cudf.Scalar(3) % x,
lambda x: cudf.Scalar(-1) + x,
lambda x: cudf.Scalar(-2) * x,
lambda x: cudf.Scalar(-2) - x,
lambda x: cudf.Scalar(-2) // x,
lambda x: cudf.Scalar(-2) / x,
lambda x: cudf.Scalar(-3) + x,
lambda x: cudf.Scalar(-3) * x,
lambda x: cudf.Scalar(-3) - x,
lambda x: cudf.Scalar(-3) // x,
lambda x: cudf.Scalar(-3) / x,
lambda x: cudf.Scalar(-3) % x,
lambda x: cudf.Scalar(0) + x,
lambda x: cudf.Scalar(0) * x,
lambda x: cudf.Scalar(0) - x,
lambda x: cudf.Scalar(0) // x,
lambda x: cudf.Scalar(0) / x,
]

pytest_xfail = pytest.mark.xfail
pytestmark = pytest.mark.spilling

# If spilling is enabled globally, we skip many test permutations
# to reduce running time.
if get_global_manager() is not None:
_binops = _binops[:1]
_binops_compare = _binops_compare[:1]
_int_types = _int_types[-1:]
_cmpops = _cmpops[:1]
_reflected_ops = _reflected_ops[:1]
_operators_arithmetic = _operators_arithmetic[:1]
_operators_comparison = _operators_comparison[:1]
_cudf_scalar_reflected_ops = _cudf_scalar_reflected_ops[:1]
DATETIME_TYPES = {"datetime64[ms]"} # noqa: F811
NUMERIC_TYPES = {"float32"} # noqa: F811
FLOAT_TYPES = {"float64"} # noqa: F811
INTEGER_TYPES = {"int16"} # noqa: F811
TIMEDELTA_TYPES = {"timedelta64[s]"} # noqa: F811
# To save time, we skip tests marked "pytest.mark.xfail"
pytest_xfail = pytest.mark.skipif


@pytest.mark.parametrize("obj_class", ["Series", "Index"])
@pytest.mark.parametrize("binop", _binops)
Expand Down Expand Up @@ -114,20 +237,6 @@ def test_series_binop_scalar(nelem, binop, obj_class, use_cudf_scalar):
np.testing.assert_almost_equal(result.to_numpy(), binop(arr, rhs))


_bitwise_binops = [operator.and_, operator.or_, operator.xor]


_int_types = [
"int8",
"int16",
"int32",
"int64",
"uint8",
"uint16",
"uint32",
]


@pytest.mark.parametrize("obj_class", ["Series", "Index"])
@pytest.mark.parametrize("binop", _bitwise_binops)
@pytest.mark.parametrize(
Expand All @@ -152,16 +261,6 @@ def test_series_bitwise_binop(binop, obj_class, lhs_dtype, rhs_dtype):
np.testing.assert_almost_equal(result.to_numpy(), binop(arr1, arr2))


_cmpops = [
operator.lt,
operator.gt,
operator.le,
operator.ge,
operator.eq,
operator.ne,
]


@pytest.mark.parametrize("obj_class", ["Series", "Index"])
@pytest.mark.parametrize("cmpop", _cmpops)
@pytest.mark.parametrize(
Expand Down Expand Up @@ -385,37 +484,6 @@ def test_series_cmpop_mixed_dtype(cmpop, lhs_dtype, rhs_dtype, obj_class):
np.testing.assert_array_equal(result.to_numpy(), cmpop(lhs, rhs))


_reflected_ops = [
lambda x: 1 + x,
lambda x: 2 * x,
lambda x: 2 - x,
lambda x: 2 // x,
lambda x: 2 / x,
lambda x: 3 + x,
lambda x: 3 * x,
lambda x: 3 - x,
lambda x: 3 // x,
lambda x: 3 / x,
lambda x: 3 % x,
lambda x: -1 + x,
lambda x: -2 * x,
lambda x: -2 - x,
lambda x: -2 // x,
lambda x: -2 / x,
lambda x: -3 + x,
lambda x: -3 * x,
lambda x: -3 - x,
lambda x: -3 // x,
lambda x: -3 / x,
lambda x: -3 % x,
lambda x: 0 + x,
lambda x: 0 * x,
lambda x: 0 - x,
lambda x: 0 // x,
lambda x: 0 / x,
]


@pytest.mark.parametrize("obj_class", ["Series", "Index"])
@pytest.mark.parametrize(
"func, dtype", list(product(_reflected_ops, utils.NUMERIC_TYPES))
Expand Down Expand Up @@ -458,37 +526,6 @@ def test_cudf_scalar_reflected_ops_scalar(func, dtype):
assert np.isclose(expected, actual)


_cudf_scalar_reflected_ops = [
lambda x: cudf.Scalar(1) + x,
lambda x: cudf.Scalar(2) * x,
lambda x: cudf.Scalar(2) - x,
lambda x: cudf.Scalar(2) // x,
lambda x: cudf.Scalar(2) / x,
lambda x: cudf.Scalar(3) + x,
lambda x: cudf.Scalar(3) * x,
lambda x: cudf.Scalar(3) - x,
lambda x: cudf.Scalar(3) // x,
lambda x: cudf.Scalar(3) / x,
lambda x: cudf.Scalar(3) % x,
lambda x: cudf.Scalar(-1) + x,
lambda x: cudf.Scalar(-2) * x,
lambda x: cudf.Scalar(-2) - x,
lambda x: cudf.Scalar(-2) // x,
lambda x: cudf.Scalar(-2) / x,
lambda x: cudf.Scalar(-3) + x,
lambda x: cudf.Scalar(-3) * x,
lambda x: cudf.Scalar(-3) - x,
lambda x: cudf.Scalar(-3) // x,
lambda x: cudf.Scalar(-3) / x,
lambda x: cudf.Scalar(-3) % x,
lambda x: cudf.Scalar(0) + x,
lambda x: cudf.Scalar(0) * x,
lambda x: cudf.Scalar(0) - x,
lambda x: cudf.Scalar(0) // x,
lambda x: cudf.Scalar(0) / x,
]


@pytest.mark.parametrize("obj_class", ["Series", "Index"])
@pytest.mark.parametrize(
"funcs, dtype",
Expand Down Expand Up @@ -652,28 +689,6 @@ def test_boolean_scalar_binop(op):
utils.assert_eq(op(psr, False), op(gsr, cudf.Scalar(False)))


_operators_arithmetic = [
"add",
"radd",
"sub",
"rsub",
"mul",
"rmul",
"mod",
"rmod",
"pow",
"rpow",
"div",
"divide",
"floordiv",
"rfloordiv",
"truediv",
"rtruediv",
]

_operators_comparison = ["eq", "ne", "lt", "le", "gt", "ge"]


@pytest.mark.parametrize("func", _operators_arithmetic)
@pytest.mark.parametrize("has_nulls", [True, False])
@pytest.mark.parametrize("fill_value", [None, 27])
Expand Down Expand Up @@ -887,7 +902,7 @@ def test_binop_bool_uint(func, rhs):
(
pytest.param(
np.bool_,
marks=pytest.mark.xfail(
marks=pytest_xfail(
reason=(
"Pandas handling of division by zero-bool is too strange"
)
Expand Down Expand Up @@ -918,7 +933,7 @@ def test_floordiv_zero_float64(series_dtype, divisor_dtype, scalar_divisor):
(
pytest.param(
np.bool_,
marks=pytest.mark.xfail(
marks=pytest_xfail(
reason=(
"Pandas handling of division by zero-bool is too strange"
)
Expand Down Expand Up @@ -1624,7 +1639,7 @@ def test_scalar_null_binops(op, dtype_l, dtype_r):
"microseconds",
pytest.param(
"nanoseconds",
marks=pytest.mark.xfail(
marks=pytest_xfail(
condition=not PANDAS_GE_150,
reason="https://github.com/pandas-dev/pandas/issues/36589",
),
Expand Down Expand Up @@ -1676,19 +1691,19 @@ def test_datetime_dateoffset_binaryop(
{"months": 2, "years": 5, "seconds": 923, "microseconds": 481},
pytest.param(
{"milliseconds": 4},
marks=pytest.mark.xfail(
marks=pytest_xfail(
reason="Pandas gets the wrong answer for milliseconds"
),
),
pytest.param(
{"milliseconds": 4, "years": 2},
marks=pytest.mark.xfail(
marks=pytest_xfail(
reason="Pandas construction fails with these keywords"
),
),
pytest.param(
{"nanoseconds": 12},
marks=pytest.mark.xfail(
marks=pytest_xfail(
reason="Pandas gets the wrong answer for nanoseconds"
),
),
Expand Down Expand Up @@ -1732,7 +1747,7 @@ def test_datetime_dateoffset_binaryop_multiple(date_col, kwargs, op):
"microseconds",
pytest.param(
"nanoseconds",
marks=pytest.mark.xfail(
marks=pytest_xfail(
condition=not PANDAS_GE_150,
reason="https://github.com/pandas-dev/pandas/issues/36589",
),
Expand Down Expand Up @@ -2754,7 +2769,7 @@ def test_binops_decimal_comp_mixed_integer(args, integer_dtype, reflected):
),
],
)
@pytest.mark.xfail(
@pytest_xfail(
reason="binop operations not supported for different "
"bit-width decimal types"
)
Expand Down Expand Up @@ -2928,7 +2943,7 @@ def decimal_series(input, dtype):
],
)
@pytest.mark.parametrize("reflected", [True, False])
@pytest.mark.xfail(
@pytest_xfail(
reason="binop operations not supported for different bit-width "
"decimal types"
)
Expand Down Expand Up @@ -3117,7 +3132,7 @@ def test_empty_column(binop, data, scalar):
cudf.DataFrame([[1, 2, 3, 4], [5, 6, 7, 8]]),
pytest.param(
cudf.DataFrame([[1, None, None, 4], [5, 6, 7, None]]),
marks=pytest.mark.xfail(
marks=pytest_xfail(
reason="Cannot access Frame.values if frame contains nulls"
),
),
Expand Down
Loading