Files
simonw--llm/tests/test_encode_decode.py
Simon Willison c12fd50b9f Ruff >= 0.16.0 (#1557)
* ruff>=0.16.0
* Fixed all ruff issues with --fix and --unsafe-fixes
* Codex (GPT-5.6 Sol High) fixed remaining Ruff errors: https://gist.github.com/simonw/53404d27979d28f66ae59564d9fb3382
* Ruff target-version = "py310"
2026-07-25 14:16:47 -07:00

21 lines
410 B
Python

import numpy as np
import pytest
import llm
@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