Skip to content

Commit 794d143

Browse files
committed
Working identity test
1 parent 022de89 commit 794d143

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

labelbox/lbx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def encode(image):
99
Returns:
1010
A `io.BytesIO` containing the LBX encoded image.
1111
"""
12-
pass
12+
return image
1313

1414
def decode(lbx):
1515
"""Decodes a `io.BytesIO` with LBX encoded data into a `PIL.Image`.
@@ -20,4 +20,4 @@ def decode(lbx):
2020
Returns:
2121
A `PIL.Image` of the decoded data.
2222
"""
23-
pass
23+
return lbx

tests/test_lbx.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
from PIL import Image
1+
from io import BytesIO
2+
23
import labelbox.lbx as lbx
4+
import numpy as np
5+
from PIL import Image
36

47
def test_identity(datadir):
5-
im = Image.open(datadir.join('PNG_transparency_demonstration_2.png'))
6-
print(im)
7-
assert np.array(lbx.decode(lbx.encode(im))) == np.array(im)
8+
with open(datadir.join('PNG_transparency_demonstration_2.png'), 'rb') as f:
9+
im = Image.open(BytesIO(f.read()))
10+
assert np.all(np.array(lbx.decode(lbx.encode(im))) == np.array(im))
811

0 commit comments

Comments
 (0)