(request, dtype_a, dtype_b)
| 100 | @pytest.mark.parametrize("dtype_a", dtypes) |
| 101 | @pytest.mark.parametrize("dtype_b", dtypes) |
| 102 | def test_binary_input_aligns_columns(request, dtype_a, dtype_b): |
| 103 | if ( |
| 104 | is_extension_array_dtype(dtype_a) |
| 105 | or isinstance(dtype_a, dict) |
| 106 | or is_extension_array_dtype(dtype_b) |
| 107 | or isinstance(dtype_b, dict) |
| 108 | ): |
| 109 | request.applymarker( |
| 110 | pytest.mark.xfail( |
| 111 | reason="Extension / mixed with multiple inputs not implemented." |
| 112 | ) |
| 113 | ) |
| 114 | |
| 115 | df1 = pd.DataFrame({"A": [1, 2], "B": [3, 4]}).astype(dtype_a) |
| 116 | |
| 117 | if isinstance(dtype_a, dict) and isinstance(dtype_b, dict): |
| 118 | dtype_b = dtype_b.copy() |
| 119 | dtype_b["C"] = dtype_b.pop("B") |
| 120 | df2 = pd.DataFrame({"A": [1, 2], "C": [3, 4]}).astype(dtype_b) |
| 121 | # As of 2.0, align first before applying the ufunc |
| 122 | result = np.heaviside(df1, df2) |
| 123 | expected = np.heaviside( |
| 124 | np.array([[1, 3, np.nan], [2, 4, np.nan]]), |
| 125 | np.array([[1, np.nan, 3], [2, np.nan, 4]]), |
| 126 | ) |
| 127 | expected = pd.DataFrame(expected, index=[0, 1], columns=["A", "B", "C"]) |
| 128 | tm.assert_frame_equal(result, expected) |
| 129 | |
| 130 | result = np.heaviside(df1, df2.values) |
| 131 | expected = pd.DataFrame([[1.0, 1.0], [1.0, 1.0]], columns=["A", "B"]) |
| 132 | tm.assert_frame_equal(result, expected) |
| 133 | |
| 134 | |
| 135 | @pytest.mark.parametrize("dtype", dtypes) |
nothing calls this directly
no test coverage detected