MCPcopy
hub / github.com/pandas-dev/pandas / validate_putmask

Function validate_putmask

pandas/core/array_algos/putmask.py:102–113  ·  view source on GitHub ↗

Validate mask and check if this putmask operation is a no-op.

(
    values: ArrayLike | MultiIndex, mask: np.ndarray
)

Source from the content-addressed store, hash-verified

100
101
102def 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
116def extract_bool_array(mask: ArrayLike) -> npt.NDArray[np.bool_]:

Callers 6

putmaskMethod · 0.90
whereMethod · 0.90
fillnaMethod · 0.90
whereMethod · 0.90
putmaskMethod · 0.90
putmaskMethod · 0.90

Calls 2

extract_bool_arrayFunction · 0.85
anyMethod · 0.45

Tested by

no test coverage detected