def test_saveandload(self): f_dict = fastdict.FastCompressUInt32Int8Dict(self.dimension) f_dict.set(123, 78912893, 0) f_dict.set(456, 789, 1) fastdict.save_compress_uint32_int8("test.dict", f_dict) another_f_dict = fastdict.FastCompressUInt32Int8Dict(self.dimension) fastdict.load_compress_uint32_int8("test.dict", another_f_dict) self.assertEqual(another_f_dict.size(), 2)
def test_keydimensions(self): f_dict = fastdict.FastCompressUInt32Int8Dict(self.dimension) f_dict.set_keydimensions([1, 2, 3]) keydimensions = [] f_dict.get_keydimensions(keydimensions) self.assertEqual(keydimensions, [1, 2, 3]) fastdict.save_compress_uint32_int8("test.dict", f_dict) another_f_dict = fastdict.FastCompressUInt32Int8Dict(self.dimension) fastdict.load_compress_uint32_int8("test.dict", another_f_dict) keydimensions = [] another_f_dict.get_keydimensions(keydimensions) self.assertEqual(keydimensions, [1, 2, 3])
def load(self, filename): if self.storage.size() > 0: if self.config['t'] == 'string': fastdict.load_compress_uint32_string(filename, self.load_dict) elif self.config['t'] == 'int8': fastdict.load_compress_uint32_int8(filename, self.load_dict) elif self.config['t'] == 'int32': fastdict.load_compress_uint32_int(filename, self.load_dict) self.storage.merge(self.load_dict) self.load_dict.clear() else: if self.config['t'] == 'string': fastdict.load_compress_uint32_string(filename, self.storage) elif self.config['t'] == 'int8': fastdict.load_compress_uint32_int8(filename, self.storage) elif self.config['t'] == 'int32': fastdict.load_compress_uint32_int(filename, self.storage) key_dimensions = [] self.storage.get_keydimensions(key_dimensions) self.key_dimensions = np.array(key_dimensions)