vak.common.validators.is_non_negative

vak.common.validators.is_non_negative(boundary_times: FloatTensor, name: str | None = None) bool[source]

Validates that y is a torch.Tensor with all non-negative (>=0.0) values.

Parameters:
  • y (torch.Tensor) – Array to be validated.

  • name (str, optional) – Name of array in calling function. Used in any error message if supplied.

Returns:

is_non_negative – True if all values in y are non-negative

Return type:

bool

Examples

>>> y = torch.tensor([0.0, 0.1, 0.,2])
>>> vak.metrics.boundary_detection.validators.is_non_negative(y)
True