def __init__ ( self, dtype = None, shape = None, value = None,
                         coerce = False, typecode = None, **metadata ):
        """ Returns an AbstractArray trait.
        """
        global ndarray, asarray

        try:
            import numpy
        except ImportError:
            raise TraitError( "Using Array or CArray trait types requires the "
                              "numpy package to be installed." )

        from numpy import asarray, ndarray

        # Mark this as being an 'array' trait:
        metadata[ 'array' ] = True

        # Normally use object identity to detect array values changing:
        metadata.setdefault( 'comparison_mode', OBJECT_IDENTITY_COMPARE )

        if typecode is not None:
            warnings.warn( 'typecode is a deprecated argument; use dtype '
                           'instead', DeprecationWarning )

            if (dtype is not None) and (dtype != typecode):
                raise TraitError( 'Inconsistent usage of the dtype and '
                                  'typecode arguments; use dtype alone.' )
            else:
                dtype = typecode

        if dtype is not None:
            try:
                # Convert the argument into an actual numpy dtype object:
                dtype = numpy.dtype( dtype )
            except TypeError:
                raise TraitError( 'could not convert %r to a numpy dtype' %
                                  dtype )

        if shape is not None:
            if isinstance( shape, SequenceTypes ):
                for item in shape:
                    if ((item is None) or (type( item ) is int) or
                        (isinstance( item, SequenceTypes ) and
                         (len( item ) == 2) and
                         (type( item[0] ) is int) and (item[0] >= 0) and
                         ((item[1] is None) or ((type( item[1] ) is int) and
                           (item[0] <= item[1]))))):
                        continue

                    raise TraitError, "shape should be a list or tuple"
            else:
                raise TraitError, "shape should be a list or tuple"

        if value is None:
            value = self._default_for_dtype_and_shape( dtype, shape )

        self.dtype  = dtype
        self.shape  = shape
        self.coerce = coerce

        super( AbstractArray, self ).__init__( value, **metadata )
dataset/ETHPy150Open enthought/traits/traits/trait_numeric.py/AbstractArray.__init__/original