class_docstr: By: Xing Shi (xingshi@usc.edu)
  
  This meta-hash performs hash permutations on binary bucket keys.
  You use this just like every other LSHash implementation and
  add the actual binary hashes you want to use via the add_child_hash
  method. Each child hash will be used separately.
  
  After all vectors have been indexed you have to call build_permuted_index
  to generate the permuted index.
  
  So to use this you have to do the following steps:
  
  1. Create HashPermutations instance and use it in the Engine constructor
  2. Add your binary hashes as child hashes by calling add_child_hash()
  3. Store your vectors using the Engine
  4. Build the permuted index by calling build_permuted_index()
  5. Now when you query the permuted index is used
  
  If you are adding more vectors afterwards you can update the permuted index
  by calling build_permuted_index() again and again.
class_docstr_tok: ["By",":","Xing","Shi","(","xingshi","@","usc.edu",")","This","meta-hash","performs","hash","permutations","on","binary","bucket","keys",".","You","use","this","just","like","every","other","LSHash","implementation","and","add","the","actual","binary","hashes","you","want","to","use","via","the","add_child_hash","method",".","Each","child","hash","will","be","used","separately",".","After","all","vectors","have","been","indexed","you","have","to","call","build_permuted_index","to","generate","the","permuted","index",".","So","to","use","this","you","have","to","do","the","following","steps",":","1",".","Create","HashPermutations","instance","and","use","it","in","the","Engine","constructor","2",".","Add","your","binary","hashes","as","child","hashes","by","calling","add_child_hash","(",")","3",".","Store","your","vectors","using","the","Engine","4",".","Build","the","permuted","index","by","calling","build_permuted_index","(",")","5",".","Now","when","you","query","the","permuted","index","is","used","If","you","are","adding","more","vectors","afterwards","you","can","update","the","permuted","index","by","calling","build_permuted_index","(",")","again","and","again","."]
docstr: Hashes the vector and returns the bucket key as string.
docstr_tok: ["Hashes","the","vector","and","returns","the","bucket","key","as","string","."]
code: def hash_vector(self, v, querying=False):
      """
      Hashes the vector and returns the bucket key as string.
      """
  
      bucket_keys = []
  
      if querying:
          # If we are querying, use the permuted indexes to get bucket keys
          for child_hash in self.child_hashes:
              lshash = child_hash["hash"]
              # Make sure the permuted index for this hash is existing
              if (
                  not lshash.hash_name
                  in self.permutation.permutedIndexs
              ):
                  raise AttributeError(
                      "Permuted index is not existing for hash with name %s"
                      % lshash.hash_name
                  )
  
              # Get regular bucket keys from hash
              for bucket_key in lshash.hash_vector(v, querying):
                  # print 'Regular bucket key %s' % bucket_key
                  # Get neighbour keys from permuted index
                  neighbour_keys = self.permutation.get_neighbour_keys(
                      lshash.hash_name, bucket_key
                  )
                  # Add them to result, but prefix with hash name
                  for n in neighbour_keys:
                      bucket_keys.append(lshash.hash_name + "_" + n)
  
      else:
          # If we are indexing (storing) just use child hashes without permuted index
          for child_hash in self.child_hashes:
              lshash = child_hash["hash"]
  
              # Get regular bucket keys from hash
              for bucket_key in lshash.hash_vector(v, querying):
                  # Register bucket key in child hash dict
                  child_hash["bucket_keys"][bucket_key] = bucket_key
                  # Append bucket key to result prefixed with child hash name
                  bucket_keys.append(
                      lshash.hash_name + "_" + bucket_key
                  )
  
      # Return all the bucket keys
      return bucket_keys
  
file_path: NearPy/nearpy/hashes/permutation/hashpermutations.py
imports: import numpy
  from nearpy.hashes import LSHash, RandomBinaryProjections, PCABinaryProjections, RandomBinaryProjectionTree
  from nearpy.hashes.permutation import Permutation
label_desc: Use image node_id 3 for calling the HashPermutations obj's underlying member method code with example usage: obj.hash_vector(v, querying) and returns: bucket_keys