code: def external2internal(xe, bounds):
      
  
      xi = np.empty_like(xe)
  
      for i, (v, bound) in enumerate(zip(xe, bounds)):
  
          a = bound[0]  # minimum
          b = bound[1]  # maximum
  
          if a == None and b == None:  # No constraints
              xi[i] = v
  
          elif b == None:  # only min
              xi[i] = np.sqrt((v - a + 1.) ** 2. - 1)
  
          elif a == None:  # only max
              xi[i] = np.sqrt((b - v + 1.) ** 2. - 1)
  
          else:  # both min and max
              xi[i] = np.arcsin((2. * (v - a) / (b - a)) - 1.)
  
      return xi
docs: Convert a series of external variables to internal variables