"""Reading raw dora payloads, independently of what they mean.""" import numpy as np def as_float32(storage) -> np.ndarray: """Read a payload as float32, whether it arrived as floats or as bytes. A node that sends its payload as a raw byte slice -- which is what a C++ node does -- produces a UInt8 arrow array even though its manifest declares Float32, so the buffer has to be reinterpreted rather than converted. """ buffer = storage.to_numpy() if buffer.dtype == np.uint8: return buffer.view(np.float32) return buffer.astype(np.float32, copy=False)