class_docstr: Low-level lattice tests 
class_docstr_tok: ["Low-level","lattice","tests"]
code: def test_ZnSphereCodec_encode_centroid(self):
      dim = 8
      r2 = 5
      ref_codec = faiss.ZnSphereCodec(dim, r2)
      codec = faiss.ZnSphereCodecRec(dim, r2)
      # print(ref_codec.nv, codec.nv)
      assert ref_codec.nv == codec.nv
      s = set()
      for i in range(ref_codec.nv):
          c = np.zeros(dim, dtype="float32")
          ref_codec.decode(i, swig_ptr(c))
          code = codec.encode_centroid(swig_ptr(c))
          assert 0 <= code < codec.nv
          s.add(code)
      assert len(s) == codec.nv
  
imports: from __future__ import print_function
  import numpy
  import unittest
  import faiss
  from common_faiss_tests import get_dataset_2
  from faiss.contrib.datasets import SyntheticDataset
  from faiss.contrib.inspect_tools import get_additive_quantizer_codebooks
label_desc: Use image node_id 2 for calling the LatticeTest obj's underlying member method code with example usage: obj.test_ZnSphereCodec_encode_centroid() without return types