(obj)
| 19 | |
| 20 | |
| 21 | def pack_array(obj): |
| 22 | if (isinstance( |
| 23 | obj, |
| 24 | (np.ndarray, np.generic))) and obj.dtype.kind in ("V", "O", "c"): |
| 25 | raise ValueError(f"Unsupported dtype: {obj.dtype}") |
| 26 | |
| 27 | if isinstance(obj, np.ndarray): |
| 28 | return { |
| 29 | b"__ndarray__": True, |
| 30 | b"data": obj.tobytes(), |
| 31 | b"dtype": obj.dtype.str, |
| 32 | b"shape": obj.shape, |
| 33 | } |
| 34 | |
| 35 | if isinstance(obj, np.generic): |
| 36 | return { |
| 37 | b"__npgeneric__": True, |
| 38 | b"data": obj.item(), |
| 39 | b"dtype": obj.dtype.str, |
| 40 | } |
| 41 | |
| 42 | return obj |
| 43 | |
| 44 | |
| 45 | def unpack_array(obj): |
nothing calls this directly
no outgoing calls
no test coverage detected