_validate_weights
Signature
_validate_weights(
x: FloatVector,
w: ArrayLike | None,
) -> FloatVector | None
What problem it solves
Centralizes validation of the weights used in weighted statistics.
Input contract
If
w is None, it returnsNoneand the caller falls back to the unweighted case.If
wis provided, it is first converted with_as_float_vector.wmust have the same shape asx.Each weight must be strictly positive.
The sum of the weights must also be strictly positive and finite.
Where it is used
Failure modes
ValueErrorifwdoes not have the same shape asxValueErrorif it contains zeros, negative values,NaNvalues, or infinitiesValueErrorif the sum of the weights is not positive
Why it stays private
It enforces a shared convention for weights without introducing an extra function into the public API.