def validate ( self, object, name, value ):
        """ Validates that the value is a valid array.
        """
        try:
            # Make sure the value is an array:
            type_value = type( value )
            if not isinstance( value, ndarray ):
                if not isinstance( value, SequenceTypes ):
                    self.error( object, name, value )
                if self.dtype is not None:
                    value = asarray( value, self.dtype )
                else:
                    value = asarray( value )

            # Make sure the array is of the right type:
            if ((self.dtype is not None) and
                (value.dtype != self.dtype)):
                if self.coerce:
                    value = value.astype( self.dtype )
                else:
                    # XXX: this also coerces.
                    value = asarray( value, self.dtype )

            # If no shape requirements, then return the value:
            trait_shape = self.shape
            if trait_shape is None:
                return value

            # Else make sure that the value's shape is compatible:
            value_shape = value.shape
            if len( trait_shape ) == len( value_shape ):
                for i, dim in enumerate( value_shape ):
                    item = trait_shape[i]
                    if item is not None:
                        if type( item ) is int:
                            if dim != item:
                                break
                        elif ((item[0] < dim) or
                              ((item[1] is not None) and (dim > item[1]))):
                            break
                else:
                    return value
        except:
            pass

        self.error( object, name, value )
dataset/ETHPy150Open enthought/traits/traits/trait_numeric.py/AbstractArray.validate/swapped operands of `<`