diff --git a/pandas/tests/arithmetic/test_numeric.py b/pandas/tests/arithmetic/test_numeric.py index 584e22f8488f5..bafd93fd67a9e 100644 --- a/pandas/tests/arithmetic/test_numeric.py +++ b/pandas/tests/arithmetic/test_numeric.py @@ -11,6 +11,7 @@ import pandas as pd from pandas import Index, Series, Timedelta, TimedeltaIndex +from pandas.conftest import all_arithmetic_functions from pandas.core import ops import pandas.util.testing as tm @@ -72,6 +73,25 @@ def test_compare_invalid(self): tm.assert_series_equal(a / b, 1 / (b / a)) +class TestNumericArraylikeArithmeticWithBool: + @pytest.mark.parametrize("num", [1.0, 1]) + def test_array_like_bool_and_num_op_coerce( + self, num, all_arithmetic_functions, box_with_array + ): + # GH 18549 + op = all_arithmetic_functions + expected = [op(num, num)] + expected = tm.box_expected(expected, box_with_array) + bool_box = tm.box_expected([True], box_with_array) + try: + tm.assert_equal(expected, op(bool_box, num)) + tm.assert_equal(expected, op(num, bool_box)) + except TypeError: + # Some operators may not be supported and that's okay. If supported + # we should should see the operation coerce to a numeric value. + pass + + # ------------------------------------------------------------------ # Numeric dtypes Arithmetic with Datetime/Timedelta Scalar