Validate mask and check if this putmask operation is a no-op.
(
values: ArrayLike | MultiIndex, mask: np.ndarray
)
| 100 | |
| 101 | |
| 102 | def validate_putmask( |
| 103 | values: ArrayLike | MultiIndex, mask: np.ndarray |
| 104 | ) -> tuple[npt.NDArray[np.bool_], bool]: |
| 105 | """ |
| 106 | Validate mask and check if this putmask operation is a no-op. |
| 107 | """ |
| 108 | mask = extract_bool_array(mask) |
| 109 | if mask.shape != values.shape: |
| 110 | raise ValueError("putmask: mask and data must be the same size") |
| 111 | |
| 112 | noop = not mask.any() |
| 113 | return mask, noop |
| 114 | |
| 115 | |
| 116 | def extract_bool_array(mask: ArrayLike) -> npt.NDArray[np.bool_]: |