validate_shape#
- stimupy.utils.validate_shape(shape)#
Put specification of shape (in pixels) in canonical form, if possible
- Parameters:
shape (Sequence of length 1 or 2; or None) – if 2 elements: interpret as (height, width) if 1 element: use as both height and width if None: return (None, None) each element has to be of type that can be cast to int, or None.
- Returns:
.height: int, height in pixels .width: int, width in pixels
- Return type:
Shape NamedTuple, with two attributes
- Raises:
ValueError – if input does not have at least 1 element
TypeError – if input is not a Sequence(int, int) and cannot be cast to one
ValueError – if input has more than 2 elements