Download packages/openpi-client/src/openpi_client/msgpack_numpy_test.py from Alan0928/VLAwithVariousSpeed: direct link, hf CLI and curl.
- Browser
- Download file 1.64 kB
-
https://huggingface.co/Alan0928/VLAwithVariousSpeed/resolve/main/packages/openpi-client/src/openpi_client/msgpack_numpy_test.py
- Command line
-
hf download hf://Alan0928/VLAwithVariousSpeed/packages/openpi-client/src/openpi_client/msgpack_numpy_test.py
-
curl -L -o msgpack_numpy_test.py https://huggingface.co/Alan0928/VLAwithVariousSpeed/resolve/main/packages/openpi-client/src/openpi_client/msgpack_numpy_test.py
1.64 kB
| import numpy as np | |
| import pytest | |
| import tree | |
| from openpi_client import msgpack_numpy | |
| def _check(expected, actual): | |
| if isinstance(expected, np.ndarray): | |
| assert expected.shape == actual.shape | |
| assert expected.dtype == actual.dtype | |
| assert np.array_equal(expected, actual, equal_nan=expected.dtype.kind == "f") | |
| else: | |
| assert expected == actual | |
| def test_pack_unpack(data): | |
| packed = msgpack_numpy.packb(data) | |
| unpacked = msgpack_numpy.unpackb(packed) | |
| tree.map_structure(_check, data, unpacked) | |