(file, array)
| 4 | import struct |
| 5 | |
| 6 | def save(file, array): |
| 7 | magic_string=b"\x93NUMPY\x01\x00v\x00" |
| 8 | header=bytes(("{'descr': '"+array.dtype.descr[0][1]+"', 'fortran_order': False, 'shape': "+str(array.shape)+", }").ljust(127-len(magic_string))+"\n",'utf-8') |
| 9 | if type(file) == str: |
| 10 | file=open(file,"wb") |
| 11 | file.write(magic_string) |
| 12 | file.write(header) |
| 13 | file.write(array.data) |
| 14 | |
| 15 | def pack(array): |
| 16 | size=len(array.shape) |