Get array from file with specified shape, dtype and file offset
Parameters : | shape : sequence
in_dtype : numpy dtype
infile : file-like
offset : int, optional
order : {‘F’, ‘C’} string
|
---|---|
Returns : | arr : array-like
|
Examples
>>> from StringIO import StringIO #23dt : BytesIO
>>> bio = StringIO() #23dt : BytesIO
>>> arr = np.arange(6).reshape(1,2,3)
>>> _ = bio.write(arr.tostring('F')) # outputs int in python3
>>> arr2 = array_from_file((1,2,3), arr.dtype, bio)
>>> np.all(arr == arr2)
True
>>> bio = StringIO() #23dt : BytesIO
>>> _ = bio.write(' ' * 10) #23dt : bytes
>>> _ = bio.write(arr.tostring('F'))
>>> arr2 = array_from_file((1,2,3), arr.dtype, bio, 10)
>>> np.all(arr == arr2)
True