def test_hash_memory_storage_pcadp(self): train_vectors = numpy.random.randn(10, 100) hash1 = PCADiscretizedProjections('testPCADPHash', 4, train_vectors, 0.1) self.memory.store_hash_configuration(hash1) hash2 = PCADiscretizedProjections(None, None, None, None) hash2.apply_config(self.memory.load_hash_configuration('testPCADPHash')) self.assertEqual(hash1.dim, hash2.dim) self.assertEqual(hash1.hash_name, hash2.hash_name) self.assertEqual(hash1.bin_width, hash2.bin_width) self.assertEqual(hash1.projection_count, hash2.projection_count) for i in range(hash1.components.shape[0]): for j in range(hash1.components.shape[1]): self.assertEqual(hash1.components[i, j], hash2.components[i, j])
def setUp(self): self.vectors = numpy.random.randn(10, 100) self.pdp = PCADiscretizedProjections('pdp', 4, self.vectors, 0.1)