validate_bool_mask#
- validate_bool_mask(mask, name, *, shape=None, size=None)[source]#
Validate that
maskis a boolean NumPy array of the expected extent.- Parameters:
mask (object) – The value to validate.
name (str) – Name of the argument, used in error messages.
shape (tuple of int, optional) – If given, the exact shape
maskmust have.size (int, optional) – If given, the exact number of elements
maskmust have. Useful when the rank is allowed to vary but the total extent is fixed.
- Returns:
The validated
mask(returned unchanged for convenient chaining).- Return type:
numpy.ndarray of bool
- Raises:
TypeError – If
maskis not anumpy.ndarray.ValueError – If
maskis not of boolean dtype or does not matchshape/size.