code: def subtest_cluster1d(self, n, k):
      rs = np.random.RandomState(123)
      x = rs.uniform(size=(n, 1)).astype("float32")
  
      clus = faiss.Clustering1D(k)
      clus.train_exact(x)
      centroids = faiss.vector_to_array(clus.centroids).reshape((-1, 1))
      obj = self.evaluate_obj(centroids, x)
  
      clus2 = faiss.Kmeans(1, k)
      clus2.train(x)
      obj2 = self.evaluate_obj(clus2.centroids, x)
      self.assertLessEqual(obj, obj2)
  
imports: from __future__ import absolute_import, division, print_function
  import numpy
  import faiss
  import unittest
  import array
  from common_faiss_tests import get_dataset_2
label_desc: Use image node_id 2 for calling the TestClustering1D obj's underlying member method code with example usage: obj.subtest_cluster1d(n, k) without return types