code: def store_vector(self, hash_name, bucket_key, v, data):
          
          mongo_key = self._format_mongo_key(hash_name, bucket_key)
  
          val_dict = {}
          val_dict['lsh'] = mongo_key
  
          # Depending on type (sparse or not) fill value dict
          if scipy.sparse.issparse(v):
              # Make sure that we are using COO format (easy to handle)
              if not scipy.sparse.isspmatrix_coo(v):
                  v = scipy.sparse.coo_matrix(v)
  
              # Construct list of [index, value] items,
              # one for each non-zero element of the sparse vector
              encoded_values = []
  
              for k in range(v.data.size):
                  row_index = v.row[k]
                  value = v.data[k]
                  encoded_values.append([int(row_index), value])
  
              val_dict['sparse'] = 1
              val_dict['nonzeros'] = encoded_values
              val_dict['dim'] = v.shape[0]
          else:
              # Make sure it is a 1d vector
              v = numpy.reshape(v, v.shape[0])
              val_dict['vector'] = v.tostring()
  
          val_dict['dtype'] = v.dtype.name
  
          # Add data if set
          if data is not None:
              val_dict['data'] = data
  
          # Push JSON representation of dict to end of bucket list
          self.mongo_object.insert_one(val_dict)
docs: Stores vector and JSON-serializable data in MongoDB with specified key.