Exemplo n.º 1
0
    def fasteval(self, type=_na.Float64):

        """fasteval(self, type=Float64) converts CharArray 'self' into
        a NumArray of the specified type.  fasteval() can't convert
        complex arrays at all, and loses precision when converting
        UInt64 or Int64.

        >>> array([["1","2"],["3","4"]]).fasteval().astype('Long')
        array([[1, 2],
               [3, 4]])
        >>> try:
        ...    array([["1","2"],["3","other"]]).fasteval()
        ... except _chararray.error:
        ...    pass
        """
        n = _na.array(shape=self._shape, type=_na.Float64)
        type = _nt.getType(type)
        _chararray.Eval((), self, n);
        if type != _na.Float64:
	    if ((type is _na.Int64) or 
		(_numinclude.hasUInt64 and type is _na.UInt64)):
                warnings.warn("Loss of precision converting to 64-bit type.  Consider using eval().", PrecisionWarning)
            return n.astype(type)
        else:
            return n
Exemplo n.º 2
0
    def fasteval(self, type=_na.Float64):
        """fasteval(self, type=Float64) converts CharArray 'self' into
        a NumArray of the specified type.  fasteval() can't convert
        complex arrays at all, and loses precision when converting
        UInt64 or Int64.

        >>> array([["1","2"],["3","4"]]).fasteval().astype('Long')
        array([[1, 2],
               [3, 4]])
        >>> try:
        ...    array([["1","2"],["3","other"]]).fasteval()
        ... except _chararray.error:
        ...    pass
        """
        n = _na.array(shape=self._shape, type=_na.Float64)
        type = _nt.getType(type)
        _chararray.Eval((), self, n)
        if type != _na.Float64:
            if ((type is _na.Int64)
                    or (_numinclude.hasUInt64 and type is _na.UInt64)):
                warnings.warn(
                    "Loss of precision converting to 64-bit type.  Consider using eval().",
                    PrecisionWarning)
            return n.astype(type)
        else:
            return n
Exemplo n.º 3
0
def _RecGetType(name):
    """Converts a type repr string into a type."""
    if name == "CharType":
        return CharType
    else:
        return _nt.getType(name)
Exemplo n.º 4
0
def _RecGetType(name):
    """Converts a type repr string into a type."""
    if name == "CharType":
        return CharType
    else:
        return _nt.getType(name)