(data, all_arithmetic_operators)
| 190 | |
| 191 | |
| 192 | def test_error_len_mismatch(data, all_arithmetic_operators): |
| 193 | # operating with a list-like with non-matching length raises |
| 194 | data, scalar = data |
| 195 | op = tm.get_op_from_name(all_arithmetic_operators) |
| 196 | |
| 197 | other = [scalar] * (len(data) - 1) |
| 198 | |
| 199 | err = ValueError |
| 200 | msg = "|".join( |
| 201 | [ |
| 202 | r"operands could not be broadcast together with shapes \(3,\) \(4,\)", |
| 203 | r"operands could not be broadcast together with shapes \(4,\) \(3,\)", |
| 204 | ] |
| 205 | ) |
| 206 | if data.dtype.kind == "b" and all_arithmetic_operators.strip("_") in [ |
| 207 | "sub", |
| 208 | "rsub", |
| 209 | ]: |
| 210 | err = TypeError |
| 211 | msg = ( |
| 212 | r"numpy boolean subtract, the `\-` operator, is not supported, use " |
| 213 | r"the bitwise_xor, the `\^` operator, or the logical_xor function instead" |
| 214 | ) |
| 215 | elif is_bool_not_implemented(data, all_arithmetic_operators): |
| 216 | msg = "operator '.*' not implemented for bool dtypes" |
| 217 | err = NotImplementedError |
| 218 | |
| 219 | for val in [other, np.array(other)]: |
| 220 | with pytest.raises(err, match=msg): |
| 221 | op(data, val) |
| 222 | |
| 223 | s = pd.Series(data) |
| 224 | with pytest.raises(err, match=msg): |
| 225 | op(s, val) |
| 226 | |
| 227 | |
| 228 | @pytest.mark.parametrize("op", ["__neg__", "__abs__", "__invert__"]) |
nothing calls this directly
no test coverage detected