MCPcopy Index your code
hub / github.com/python/cpython / test_train_dict

Method test_train_dict

Lib/test/test_zstd.py:1287–1306  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1285 ZstdDecompressor((zd, -2**1000))
1286
1287 def test_train_dict(self):
1288 TRAINED_DICT = train_dict(SAMPLES, DICT_SIZE1)
1289 ZstdDict(TRAINED_DICT.dict_content, is_raw=False)
1290
1291 self.assertNotEqual(TRAINED_DICT.dict_id, 0)
1292 self.assertGreater(len(TRAINED_DICT.dict_content), 0)
1293 self.assertLessEqual(len(TRAINED_DICT.dict_content), DICT_SIZE1)
1294 self.assertTrue(re.match(r'^<ZstdDict dict_id=\d+ dict_size=\d+>$', str(TRAINED_DICT)))
1295
1296 # compress/decompress
1297 c = ZstdCompressor(zstd_dict=TRAINED_DICT)
1298 for sample in SAMPLES:
1299 dat1 = compress(sample, zstd_dict=TRAINED_DICT)
1300 dat2 = decompress(dat1, TRAINED_DICT)
1301 self.assertEqual(sample, dat2)
1302
1303 dat1 = c.compress(sample)
1304 dat1 += c.flush()
1305 dat2 = decompress(dat1, TRAINED_DICT)
1306 self.assertEqual(sample, dat2)
1307
1308 def test_finalize_dict(self):
1309 DICT_SIZE2 = 200*_1K

Callers

nothing calls this directly

Calls 12

train_dictFunction · 0.90
compressFunction · 0.90
decompressFunction · 0.90
strFunction · 0.85
assertNotEqualMethod · 0.80
assertGreaterMethod · 0.80
assertLessEqualMethod · 0.80
assertTrueMethod · 0.80
matchMethod · 0.45
assertEqualMethod · 0.45
compressMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected