utils#

Methods for validating function arguments.

hsr4hci.utils.check_cartesian_position(position, require_int=False)[source]#

Check if a given position represents a valid Cartesian position (i.e., is a 2-tuple of floats or integers).

Parameters:
  • position (Any) โ€“ Variable to check whether it is a valid position.

  • require_int (bool) โ€“ Whether we require all entries of the position to be integers (e.g., because we want to use position to index an array).

Returns:

None is position is a valid Cartesian position; otherwise, a ValueError is raised.

Return type:

bool

hsr4hci.utils.check_consistent_size(*arrays, axis=0)[source]#

Check that all arrays have a consistent size along the given axis. Can be used, for example, to ensure that a given stack and parang have the same number of frames.

Parameters:
  • *arrays (ndarray) โ€“ The (numpy) arrays that will be checked.

  • axis (int) โ€“ The axis along which to check for consistent sizes. Per default, this is the temporal axis (axis = 0).

Returns:

None if all arrays have consistent sizes; otherwise, a ValueError is raised.

Return type:

bool

hsr4hci.utils.check_frame_size(frame_size)[source]#

Check if a given frame_size tuple represents a valid frame size (i.e., is a 2-tuple of positive integers).

Parameters:

frame_size (Any) โ€“ Variable which to check whether it represents a valid frame size.

Returns:

None if frame_size is a valid frame size; otherwise, a ValueError is raised.

Return type:

bool