clamp

m3sh.linalg.clamp(x, lo, hi)[source]

Clamp value to range.

Clamp x to the closed interval [lo, hi].

Parameters:
  • x (float) – Value to clamp.

  • lo (float) – Lower bound.

  • hi (float) – Upper bound.

Returns:

Clamped value.

Return type:

float

Note

To prevent data type changes arguments should not mix int and float values.