def _read_data(self, fh, byteorder='<STR_LIT:>>'):
fh.seek(len(self.header))<EOL>data = fh.read()<EOL>dtype = '<STR_LIT>' if self.maxval < <NUM_LIT> else byteorder + '<STR_LIT>'<EOL>depth = <NUM_LIT:1> if self.magicnum == b"<STR_LIT>" else self.depth<EOL>shape = [-<NUM_LIT:1>, self.height, self.width, depth]<EOL>size = numpy.prod(shape[<NUM_LIT:1>:])<EOL>if self.magicnum in b"<STR_LIT>":<EOL><INDENT>data = numpy.array(data.split(None, size)[:size], dtype)<EOL>data = data.reshape(shape)<EOL><DEDENT>elif self.maxval == <NUM_LIT:1>:<EOL><INDENT>shape[<NUM_LIT:2>] = int(math.ceil(self.width / <NUM_LIT:8>))<EOL>data = numpy.frombuffer(data, dtype).reshape(shape)<EOL>data = numpy.unpackbits(data, axis=-<NUM_LIT:2>)[:, :, :self.width, :]<EOL><DEDENT>else:<EOL><INDENT>data = numpy.frombuffer(data, dtype)<EOL>data = data[:size * (data.size // size)].reshape(shape)<EOL><DEDENT>if data.shape[<NUM_LIT:0>] < <NUM_LIT:2>:<EOL><INDENT>data = data.reshape(data.shape[<NUM_LIT:1>:])<EOL><DEDENT>if data.shape[-<NUM_LIT:1>] < <NUM_LIT:2>:<EOL><INDENT>data = data.reshape(data.shape[:-<NUM_LIT:1>])<EOL><DEDENT>if self.magicnum == b"<STR_LIT>":<EOL><INDENT>rgb332 = numpy.array(list(numpy.ndindex(<NUM_LIT:8>, <NUM_LIT:8>, <NUM_LIT:4>)), numpy.uint8)<EOL>rgb332 *= [<NUM_LIT>, <NUM_LIT>, <NUM_LIT>]<EOL>data = numpy.take(rgb332, data, axis=<NUM_LIT:0>)<EOL><DEDENT>return data<EOL>
Return image data from open file as numpy array.