def _fromdata(self, data, maxval=None):
data = numpy.array(data, ndmin=<NUM_LIT:2>, copy=True)<EOL>if data.dtype.kind not in "<STR_LIT>":<EOL><INDENT>raise ValueError("<STR_LIT>" % data.dtype)<EOL><DEDENT>if data.dtype.kind == '<STR_LIT:i>' and numpy.min(data) < <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>" % numpy.min(data))<EOL><DEDENT>if maxval is None:<EOL><INDENT>maxval = numpy.max(data)<EOL>maxval = <NUM_LIT:255> if maxval < <NUM_LIT> else <NUM_LIT><EOL><DEDENT>if maxval < <NUM_LIT:0> or maxval > <NUM_LIT>:<EOL><INDENT>raise ValueError("<STR_LIT>" % maxval)<EOL><DEDENT>data = data.astype('<STR_LIT>' if maxval < <NUM_LIT> else '<STR_LIT>')<EOL>self._data = data<EOL>if data.ndim > <NUM_LIT:2> and data.shape[-<NUM_LIT:1>] in (<NUM_LIT:3>, <NUM_LIT:4>):<EOL><INDENT>self.depth = data.shape[-<NUM_LIT:1>]<EOL>self.width = data.shape[-<NUM_LIT:2>]<EOL>self.height = data.shape[-<NUM_LIT:3>]<EOL>self.magicnum = b'<STR_LIT>' if self.depth == <NUM_LIT:4> else b'<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>self.depth = <NUM_LIT:1><EOL>self.width = data.shape[-<NUM_LIT:1>]<EOL>self.height = data.shape[-<NUM_LIT:2>]<EOL>self.magicnum = b'<STR_LIT>' if maxval > <NUM_LIT:1> else b'<STR_LIT>'<EOL><DEDENT>self.maxval = maxval<EOL>self.tupltypes = [self._types[self.magicnum]]<EOL>self.header = self._header()<EOL>
Initialize instance from numpy array.