entente.validation module¶
-
entente.validation.
validate_shape
(a, *shape, **kwargs)[source]¶ Check that the given argument has the expected shape. Shape dimensions can be ints or -1 for a wildcard. The wildcard dimensions are returned, which allows them to be used for subsequent validation or elsewhere in the function.
Parameters: - a (np.arraylike) – An array-like input.
- shape (list) – Shape to validate. To require 3 by 1, pass 3. To require n by 3, pass -1, 3.
- name (str) – Variable name to embed in the error message.
Returns: The wildcard dimension (if one) or a tuple of wildcard dimensions (if more than one).
Return type: object
-
entente.validation.
validate_shape_from_ns
(namespace, name, *shape)[source]¶ Convenience function for invoking validate_shape() with a locals() dict.
Parameters: - namespace (dict) – A subscriptable object, typically locals().
- name (str) – Key to pull from namespace.
- shape (list) – Shape to validate. To require 3 by 1, pass 3. To require n by 3, pass -1, 3.
Returns: The wildcard dimension (if one) or a tuple of wildcard dimensions (if more than one).
Return type: object
Example
validate_shape_from_namespace(locals(), ‘points’, -1, 3)