(data)
| 30 | return np.ndarray(shape, dtype=descr, buffer=file.read(datasize)) |
| 31 | |
| 32 | def unpack(data): |
| 33 | dtype = str(data[:2],'utf-8') |
| 34 | dtype += str(data[2]) |
| 35 | size = data[3] |
| 36 | shape = struct.unpack_from(f'<{size}I', data, 4) |
| 37 | datasize=data[2] |
| 38 | for dimension in shape: |
| 39 | datasize *= dimension |
| 40 | return np.ndarray(shape, dtype=dtype, buffer=data[4+size*4:4+size*4+datasize]) |
| 41 | |
| 42 | |
| 43 |