validate_array
(function from pyomo.contrib.pyros.uncertainty_sets
)
- pyomo.contrib.pyros.uncertainty_sets.validate_array(arr, arr_name, dim, valid_types, valid_type_desc=None, required_shape=None, required_shape_qual='')[source]
Validate shape and entry types of an array-like object.
- Parameters:
arr (array_like) – Object to validate.
arr_name (str) – A name/descriptor of the object to validate. Usually, this is the name of an object attribute to which the array is meant to be set.
dim (int) – Required dimension of the array-like object.
valid_types (set[type]) – Allowable type(s) for each entry of the array.
valid_type_desc (str or None, optional) – Descriptor for the allowable types.
required_shape (list or None, optional) – Specification of the length of the array in each dimension. If None is provided, no specifications are imposed. If a list is provided, then each entry of the list must be an int specifying the required length in the dimension corresponding to the position of the entry or None (meaning no requirement for the length in the corresponding dimension).
required_shape_qual (str, optional) – Clause/phrase expressing reason arr should be of shape required_shape, e.g. “to match the set dimension”.
- Raises:
ValueError – If the Numpy array to which arr is cast is not of shape required_shape.