def __init__(self, ptype=None, none=True, check=None, npdim=None,<EOL>npshape=None, npdtype=None, doc=None):
self.ptype = ptype<EOL>self.none = none<EOL>self.check = check<EOL>if doc is None:<EOL><INDENT>doc = "<STR_LIT>"<EOL><DEDENT>self.doc = doc<EOL>if ptype is not None:<EOL><INDENT>if issubclass(ptype, list):<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>if issubclass(ptype, np.ndarray):<EOL><INDENT>if not (npdim is None or isinstance(npdim, int)):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>if not (npshape is None or (isinstance(npshape, tuple) and<EOL>all(isinstance(s, int) or s is None for s<EOL>in npshape))):<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>self.npdim = npdim<EOL>self.npshape = npshape<EOL>self.npdtype = npdtype<EOL><DEDENT><DEDENT>elif not (npdim is None and npshape is None and npdtype is None):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>self.__doc__ = "<STR_LIT>" % doc<EOL>check_lines = []<EOL>if not self.none:<EOL><INDENT>check_lines.append("<STR_LIT>")<EOL><DEDENT>if self.ptype is not None:<EOL><INDENT>check_lines.append("<STR_LIT>" % self.ptype)<EOL>if issubclass(ptype, np.ndarray):<EOL><INDENT>if self.npdim is not None:<EOL><INDENT>check_lines.append("<STR_LIT>" % self.npdim)<EOL><DEDENT>if self.npshape is not None:<EOL><INDENT>tmp = []<EOL>for s in self.npshape:<EOL><INDENT>if s is None:<EOL><INDENT>tmp.append("<STR_LIT:?>")<EOL><DEDENT>else:<EOL><INDENT>tmp.append(str(s))<EOL><DEDENT><DEDENT>shape_str = "<STR_LIT>" % ("<STR_LIT:U+002CU+0020>".join(tmp))<EOL>check_lines.append("<STR_LIT>" % shape_str)<EOL><DEDENT>if self.npdtype is not None:<EOL><INDENT>check_lines.append("<STR_LIT>" % self.npdtype)<EOL><DEDENT><DEDENT><DEDENT>if check is not None:<EOL><INDENT>check_lines.append("<STR_LIT>" % check.__doc__)<EOL><DEDENT>if len(check_lines) > <NUM_LIT:0>:<EOL><INDENT>self.__doc__ += "<STR_LIT>" + "<STR_LIT>".join(check_lines)<EOL><DEDENT>self.attribute_name = "<STR_LIT>" % id(self)<EOL>
One can impose detailed type checking on the attribute through the
following options.

Optional arguments:
 | ``ptype`` -- The expected (Python) type of the attribute.
 | ``none`` -- When False, it is not possible to assign None.
 | ``npdim`` -- In case of numpy arrays: the number of dimensions.
 | ``npshape`` -- In case of numpy arrays: the expected shape.
 | ``npdtype`` -- In case of numpy arrays: the expected dtype.
 | ``check`` -- A method to check the validity of the attribute.
 | ``doc`` -- Short description.

The npshape option must be a tuple with integer or None values. In
case of a None value, the corresponding shape in the attribute is
not tested. Trailing None values from the npshape argument can be
omitted.