@classmethod<EOL><INDENT>def parse(cls, fptr, offset, length):<DEDENT>
num_bytes = offset + length - fptr.tell()<EOL>read_buffer = fptr.read(num_bytes)<EOL>nrows, ncols = struct.unpack_from('<STR_LIT>', read_buffer, offset=<NUM_LIT:0>)<EOL>bps_signed = struct.unpack_from('<STR_LIT:>>' + '<STR_LIT:B>' * ncols, read_buffer,<EOL>offset=<NUM_LIT:3>)<EOL>bps = [((x & <NUM_LIT>) + <NUM_LIT:1>) for x in bps_signed]<EOL>signed = [((x & <NUM_LIT>) > <NUM_LIT:1>) for x in bps_signed]<EOL>if any(signed) or len(set(bps)) != <NUM_LIT:1>:<EOL><INDENT>msg = ("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>raise IOError(msg)<EOL><DEDENT>b = bps[<NUM_LIT:0>]<EOL>dtype = np.uint8 if b <=<NUM_LIT:8> else np.uint16 if b <= <NUM_LIT:16> else np.uint32<EOL>palette = np.frombuffer(read_buffer[<NUM_LIT:3> + ncols:], dtype=dtype)<EOL>palette = np.reshape(palette, (nrows, ncols))<EOL>return cls(palette, bps, signed, length=length, offset=offset)<EOL>
Parse palette box.

        Parameters
        ----------
        fptr : file
            Open file object.
        offset : int
            Start position of box in bytes.
        length : int
            Length of the box in bytes.

        Returns
        -------
        PaletteBox
            Instance of the current palette box.