-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #171 from plotly/andrew/test_encoder
Andrew/test encoder
- Loading branch information
Showing
9 changed files
with
554 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from datetime import datetime | ||
|
||
import numpy as np | ||
|
||
from choreographer.pipe import Pipe | ||
|
||
data = [1, 2.00, 3, float("nan"), float("inf"), float("-inf"), datetime(1970, 1, 1)] | ||
expected_message = b'[1, 2.0, 3, null, null, null, "1970-01-01T00:00:00"]\x00' | ||
converted_type = [int, float, int, type(None), type(None), type(None), str] | ||
|
||
def test_de_serialize(): | ||
pipe = Pipe() | ||
message = pipe.serialize(data) | ||
assert message == expected_message | ||
obj = pipe.deserialize(message[:-1]) # split out \0 | ||
for o, t in zip(obj, converted_type): | ||
assert isinstance(o, t) | ||
message_np = pipe.serialize(np.array(data)) | ||
assert message_np == expected_message | ||
obj_np = pipe.deserialize(message_np[:-1]) # split out \0 | ||
for o, t in zip(obj_np, converted_type): | ||
assert isinstance(o, t) | ||
|
||
|
||
# TODO: Not sure if this all the data we have to worry about: | ||
# we should also run through mocks and have it print data. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.