class_docstr: This meta-hash performs permutations on binary bucket keys
  and keeps a dictionary for this mapping.
  
  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.
  
  So to use this you have to do the following steps:
  
  1. Create HashPermutationMapper 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. Now when you query the bucket key map is used
class_docstr_tok: ["This","meta-hash","performs","permutations","on","binary","bucket","keys","and","keeps","a","dictionary","for","this","mapping",".","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",".","So","to","use","this","you","have","to","do","the","following","steps",":","1",".","Create","HashPermutationMapper","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",".","Now","when","you","query","the","bucket","key","map","is","used"]
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 bucket key map
          for lshash in self.child_hashes:
              # Get regular bucket keys from hash
              for bucket_key in lshash.hash_vector(v, querying):
                  prefixed_key = lshash.hash_name + "_" + bucket_key
                  # Get entries from map (bucket keys with hamming distance of 1)
                  if prefixed_key in self.bucket_key_map:
                      bucket_keys.extend(
                          self.bucket_key_map[prefixed_key].keys()
                      )
      else:
          # If we are indexing (storing) just use child hashes without permuted index
          for lshash in self.child_hashes:
              # Get regular bucket keys from hash
              for bucket_key in lshash.hash_vector(v, querying):
                  # Get permuted keys
                  perm_keys = self.permuted_keys(bucket_key)
                  # Put exact hit key into list
                  perm_keys.append(bucket_key)
  
                  # Append key for storage (not the permutations)
                  bucket_keys.append(
                      lshash.hash_name + "_" + bucket_key
                  )
  
                  # For every permutation register all the variants
                  for perm_key in perm_keys:
                      prefixed_key = lshash.hash_name + "_" + perm_key
  
                      # Make sure dictionary exists
                      if not prefixed_key in self.bucket_key_map:
                          self.bucket_key_map[prefixed_key] = {}
  
                      for variant in perm_keys:
                          prefixed_variant = (
                              lshash.hash_name + "_" + variant
                          )
                          self.bucket_key_map[prefixed_key][
                              prefixed_variant
                          ] = 1
  
      # Return all the bucket keys
      return bucket_keys
  
file_path: NearPy/nearpy/hashes/permutation/hashpermutationmapper.py
imports: import numpy
  from nearpy.hashes import LSHash, RandomBinaryProjections, PCABinaryProjections, RandomBinaryProjectionTree
label_desc: Use image node_id 4 for calling the HashPermutationMapper obj's underlying member method code with example usage: obj.hash_vector(v, querying) and returns: bucket_keys