validate_numeric_array#
- validate_numeric_array(arr, name, *, shape=None, size=None)[source]#
Validate that
arris a numeric NumPy array of the expected extent.A numeric dtype is any integer, unsigned-integer, floating, or complex dtype; real arrays are accepted where a complex field is expected because they are a valid special case.
- Parameters:
arr (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
arrmust have.size (int, optional) – If given, the exact number of elements
arrmust have.
- Returns:
The validated
arr(returned unchanged for convenient chaining).- Return type:
numpy.ndarray
- Raises:
TypeError – If
arris not anumpy.ndarray.ValueError – If
arris not numeric or does not matchshape/size.