Last active
June 24, 2018 10:54
-
-
Save JPFrancoia/37246e016e4fba56363423497a8b75b7 to your computer and use it in GitHub Desktop.
Equivalent to Matlab fread function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fread(fid, nelements, dtype): | |
"""Equivalent to Matlab fread function""" | |
if dtype is np.str: | |
dt = np.uint8 # WARNING: assuming 8-bit ASCII for np.str! | |
else: | |
dt = dtype | |
data_array = np.fromfile(fid, dt, nelements) | |
data_array.shape = (nelements, 1) | |
return data_array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment