예제 #1
0
 def astype(self, dtype):
     '''
     Convert to another data type.
     
     :param dtype: (*string*) Data type.
     
     :returns: (*array*) Converted array.
     '''
     if dtype == 'int' or dtype is int:
         r = NDArray(ArrayUtil.toInteger(self._array))
     elif dtype == 'float' or dtype is float:
         r = NDArray(ArrayUtil.toFloat(self._array))
     elif dtype == 'boolean' or dtype == 'bool' or dtype is bool:
         r = NDArray(ArrayUtil.toBoolean(self._array))
     else:
         r = self
     return r
예제 #2
0
 def astype(self, dtype):
     '''
     Convert to another data type.
     
     :param dtype: (*string*) Data type.
     
     :returns: (*array*) Converted array.
     '''
     if not isinstance(dtype, _dtype.DataType):
         dtype = _dtype.DataType(dtype)
     if dtype.kind == 'i':
         r = NDArray(ArrayUtil.toInteger(self._array))
     elif dtype.kind == 'f':
         r = NDArray(ArrayUtil.toFloat(self._array))
     elif dtype.kind == 'b':
         r = NDArray(ArrayUtil.toBoolean(self._array))
     else:
         r = self
     return r