From 4cbc085a21a3d142d2593c612611b138bff58e4b Mon Sep 17 00:00:00 2001 From: Richard Bowman Date: Mon, 5 Jan 2026 20:50:37 +0000 Subject: [PATCH] Relax test for numpy over HTTP This removes the check that the ThingClient returns an ndarray instance, instead only checking that the right value is returned as a list of numbers. I've also added a test for reading a property that's a numpy array. --- tests/test_numpy_type.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_numpy_type.py b/tests/test_numpy_type.py index 822ecebf..cf1d5c9d 100644 --- a/tests/test_numpy_type.py +++ b/tests/test_numpy_type.py @@ -75,6 +75,10 @@ def action_with_arrays(self, a: NDArray) -> NDArray: def read_array(self) -> NDArray: return np.array([1, 2]) + @lt.property + def array_property(self) -> NDArray: + return np.array([3, 4, 5]) + def test_thing_description(): """Make sure the TD validates when numpy types are used.""" @@ -115,6 +119,8 @@ def test_numpy_over_http(): with TestClient(server.app) as client: np_thing_client = lt.ThingClient.from_url("/np_thing/", client=client) + arrayprop = np_thing_client.array_property + assert np.array_equal(np.asarray(arrayprop), np.array([3, 4, 5])) + array = np_thing_client.read_array() - assert isinstance(array, np.ndarray) - assert np.array_equal(array, np.array([1, 2])) + assert np.array_equal(np.asarray(array), np.array([1, 2]))