mlnext.utils.check_size#

mlnext.utils.check_size(*arrays: ndarray, size: int, axis: int, strict: bool = True)[source]#

Checks whether each array has exactly size elements along axis, if strict is false then it must be at most size elements. If strict is false and the axis is missing, then the array is ignored.

Parameters:
  • size (int) – Number of elements along the axis.

  • axis (int) – Axis to check.

  • strict (bool, optional) – If true the check is exact, otherwise at most.

Raises:

ValueError – Raised when the axis is missing or the size requirement is not fulfilled.

Example

>>> mlnext.utils.check_size(np.ones((10, 1)), np.ones((10, 3)),
...                         size=10, axis=0)