MCPcopy Create free account
hub / github.com/divideconcept/fastnumpyio / save

Function save

fastnumpyio.py:6–13  ·  view source on GitHub ↗
(file, array)

Source from the content-addressed store, hash-verified

4import struct
5
6def 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
15def pack(array):
16 size=len(array.shape)

Callers 1

fastnumpyio.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected