

def get_matfile_version(fileobj):
    '\n    Return major, minor tuple depending on apparent mat file type\n\n    Where:\n\n     #. 0,x -> version 4 format mat files\n     #. 1,x -> version 5 format mat files\n     #. 2,x -> version 7.3 format mat files (HDF format)\n\n    Parameters\n    ----------\n    fileobj : file_like\n        object implementing seek() and read()\n\n    Returns\n    -------\n    major_version : {0, 1, 2}\n        major MATLAB File format version\n    minor_version : int\n        minor MATLAB file format version\n\n    Raises\n    ------\n    MatReadError\n        If the file is empty.\n    ValueError\n        The matfile version is unknown.\n\n    Notes\n    -----\n    Has the side effect of setting the file read pointer to 0\n    '
    fileobj.seek(0)
    mopt_bytes = fileobj.read(4)
    if (len(mopt_bytes) == 0):
        raise MatReadError('Mat file appears to be empty')
    mopt_ints = np.ndarray(shape=(4,), dtype=np.uint8, buffer=mopt_bytes)
    if (0 in mopt_ints):
        fileobj.seek(0)
        return (0, 0)
    fileobj.seek(124)
    tst_str = fileobj.read(4)
    fileobj.seek(0)
    maj_ind = int((tst_str[2] == b'I'[0]))
    maj_val = byteord(tst_str[maj_ind])
    min_val = byteord(tst_str[(1 - maj_ind)])
    ret = (maj_val, fileobj)
    if (maj_val in (1, 2)):
        return ret
    raise ValueError(('Unknown mat file type, version %s, %s' % ret))

dataset/ETHPy150Open scipy/scipy/scipy/io/matlab/miobase.py get_matfile_version/VarMisuse@164/507 `min_val`->`fileobj`