torchsig.utils.verify.verify_numpy_array

torchsig.utils.verify.verify_numpy_array(n: ndarray, name: str, min_length: int | None = None, max_length: int | None = None, exact_length: int | None = None, data_type=None) ndarray[source]

Verifies that the value n is a NumPy array and optionally checks its length or item types.

Parameters:
  • n (np.ndarray) – The value to be checked.

  • name (str) – The name of the value to be used in error messages.

  • min_length (int, optional) – The minimum length of the array. Defaults to None.

  • max_length (int, optional) – The maximum length of the array. Defaults to None.

  • exact_length (int, optional) – The exact length of the array. Defaults to None.

  • data_type (type, optional) – The type each item in the array should have. Defaults to None.

Raises:

ValueError – If n is not a NumPy array or its length is not within the specified bounds, or if any item in the array is not of the required type.

Returns:

The verified NumPy array n.

Return type:

np.ndarray