code: def check_int(num,
                num_descr='number',
                min_value=0,
                max_value=np.Inf):
      
  
      if not np.isfinite(num) or num < min_value or num > max_value:
          raise ValueError('{}={} is not finite or '
                           'is not >= {} or '
                           'is not < {}'.format(num_descr, num, min_value, max_value))
  
      return int(num)
docs: Validation and typecasting.