-
-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NumPy decoding docs, plus extra tests for llm.encode/decode
!stable-docs Refs https://discord.com/channels/823971286308356157/1128504153841336370/1151975583237034056
- Loading branch information
Showing
3 changed files
with
29 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import llm | ||
import pytest | ||
import numpy as np | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"array", | ||
( | ||
(0.0, 1.0, 1.5), | ||
(3423.0, 222.0, -1234.5), | ||
), | ||
) | ||
def test_roundtrip(array): | ||
encoded = llm.encode(array) | ||
decoded = llm.decode(encoded) | ||
assert decoded == array | ||
# Try with numpy as well | ||
numpy_decoded = np.frombuffer(encoded, "<f4") | ||
assert tuple(numpy_decoded.tolist()) == array |