code: def vec_to_surface(vec):
          
          miller = [None] * 3
          index = []
          for i, value in enumerate(vec):
              if abs(value) < 1.e-8:
                  miller[i] = 0
              else:
                  index.append(i)
          if len(index) == 1:
              miller[index[0]] = 1
          else:
              min_index = np.argmin([i for i in vec if i != 0])
              true_index = index[min_index]
              index.pop(min_index)
              frac = []
              for i, value in enumerate(index):
                  frac.append(Fraction(vec[value] / vec[true_index]).limit_denominator(100))
              if len(index) == 1:
                  miller[true_index] = frac[0].denominator
                  miller[index[0]] = frac[0].numerator
              else:
                  com_lcm = lcm(frac[0].denominator, frac[1].denominator)
                  miller[true_index] = com_lcm
                  miller[index[0]] = frac[0].numerator * int(round((com_lcm / frac[0].denominator)))
                  miller[index[1]] = frac[1].numerator * int(round((com_lcm / frac[1].denominator)))
          return miller
docs: Transform a float vector to a surface miller index with integers.
  
          Args:
              vec (1 by 3 array float vector): input float vector
          Return:
              the surface miller index of the input vector.