We use numpy a lot, so it would be great to be able to type hint numpy properly.
Currently we have to use: from labthings_fastapi.types.numpy import NDArray which works for sending things over HTTP but means the type hints are wrong when using the action from within the server.
Proposal
- Allow
np.ndarray
- On seeing
np.ndarray LabThings should convert it to a pydantic model this model can have the necessary data to reconstruct the array including dimensions and types
class NDArrayModel(BaseModel):
shape = list[int]
d_type = Literal["bool"], Literal["int"], Literal["float"], Literal["uint8"], Literal["uint16"]
data = list[int]|list[bool]|list[float]
This way we can serialise the data as a 1D list along with the information for how to contruct the correct array. In a ThingClient the array should be able to be reconstructed. In Javascript or any other language there is enough information to process the result.
We use numpy a lot, so it would be great to be able to type hint numpy properly.
Currently we have to use:
from labthings_fastapi.types.numpy import NDArraywhich works for sending things over HTTP but means the type hints are wrong when using the action from within the server.Proposal
np.ndarraynp.ndarrayLabThings should convert it to a pydantic model this model can have the necessary data to reconstruct the array including dimensions and typesThis way we can serialise the data as a 1D list along with the information for how to contruct the correct array. In a
ThingClientthe array should be able to be reconstructed. In Javascript or any other language there is enough information to process the result.