def shape_from_header(self, hdr):
mclass = hdr.mclass<EOL>if mclass == mxFULL_CLASS:<EOL><INDENT>shape = tuple(map(int, hdr.dims))<EOL><DEDENT>elif mclass == mxCHAR_CLASS:<EOL><INDENT>shape = tuple(map(int, hdr.dims))<EOL>if self.chars_as_strings:<EOL><INDENT>shape = shape[:-<NUM_LIT:1>]<EOL><DEDENT><DEDENT>elif mclass == mxSPARSE_CLASS:<EOL><INDENT>dt = hdr.dtype<EOL>dims = hdr.dims<EOL>if not (len(dims) == <NUM_LIT:2> and dims[<NUM_LIT:0>] >= <NUM_LIT:1> and dims[<NUM_LIT:1>] >= <NUM_LIT:1>):<EOL><INDENT>return ()<EOL><DEDENT>self.mat_stream.seek(dt.itemsize * (dims[<NUM_LIT:0>] - <NUM_LIT:1>), <NUM_LIT:1>)<EOL>rows = np.ndarray(shape=(<NUM_LIT:1>,), dtype=dt,<EOL>buffer=self.mat_stream.read(dt.itemsize))<EOL>self.mat_stream.seek(dt.itemsize * (dims[<NUM_LIT:0>] - <NUM_LIT:1>), <NUM_LIT:1>)<EOL>cols = np.ndarray(shape=(<NUM_LIT:1>,), dtype=dt,<EOL>buffer=self.mat_stream.read(dt.itemsize))<EOL>shape = (int(rows), int(cols))<EOL><DEDENT>else:<EOL><INDENT>raise TypeError('<STR_LIT>' % mclass)<EOL><DEDENT>if self.squeeze_me:<EOL><INDENT>shape = tuple([x for x in shape if x != <NUM_LIT:1>])<EOL><DEDENT>return shape<EOL>
Read the shape of the array described by the header.
        The file position after this call is unspecified.