Skip to content

Instantly share code, notes, and snippets.

@aadps
Created May 5, 2020 09:20
Show Gist options
  • Save aadps/69fc585b452ac70699af7eca0287250d to your computer and use it in GitHub Desktop.
Save aadps/69fc585b452ac70699af7eca0287250d to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import lilcom
import numpy as np
a = np.empty((0))
b = lilcom.compress(a)
assert b[0] == 76
assert b[1] == 0
print("Header begins with \"L0\"")
try:
lilcom.decompress(bytes())
except ValueError as e:
print(e.args[0])
assert e.args[0] == "lilcom: Length of string was too short"
pass
try:
lilcom.decompress(bytes("X00", "utf-8"))
except ValueError as e:
print(e.args[0])
assert e.args[0] == "lilcom: Lilcom-compressed data must begin with L"
pass
try:
lilcom.decompress(bytes("L10", "utf-8"))
except ValueError as e:
print(e.args[0])
assert e.args[0] == "lilcom: Trying to decompress data from a future "\
"format version (use newer code)"
pass
@danpovey
Copy link

danpovey commented May 5, 2020

Fantastic! You can make a PR including my changes plus your change, to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment