code: def _trunc(x, minval=None, maxval=None):
      
      x = np.copy(x)
      if minval is not None:
          x[x < minval] = minval
      if maxval is not None:
          x[x > maxval] = maxval
      return x
docs: Truncate vector values to have values on range [minval, maxval]