def __setitem__(self, key, value):
        value = fromDS(value)
        if isinstance(value, ndarray):
            value = value._jdataset()

        if isinstance(key, ndarray):
            key = key._jdataset()
            if isinstance(key, _booleands):
                return self.__dataset.setByBoolean(value, key)
            if isinstance(key, _integerds): #FIXME
                return self.__dataset.setByIndex(value, key)

        isslice, key = self._toslice(key)
        try:
            if isslice:
                _setslice(self.__dataset, value, key)
                return self
            value = _cvt2j(value)
            return self.__dataset.set(value, key)
        except _jarrayindex_exception:
            raise IndexError
示例#2
0
def __cvt_jobj(obj, dtype=None, copy=True, force=False):
    '''Convert object to java object'''
    if isinstance(obj, ndarray):
        obj = obj._jdataset()

    if isinstance(obj, _ds):
        if copy:
            if dtype is None or _translatenativetype(dtype).value == obj.dtype:
                return obj.clone()
            else:
                return obj.cast(_translatenativetype(dtype).value)
        else:
            if dtype is None:
                return obj
            return obj.cast(_translatenativetype(dtype).value)

    if not isinstance(obj, list):
        if isinstance(obj, _matrix): # cope with JAMA matrices
            if dtype is None:
                dtype = float64
            obj = obj.getArray()
    elif len(obj) == 0 and dtype is None:
        dtype = float64

    obj = _cvt2j(obj)
    try:
        iter(obj)
    except:
        if not force:
            if isinstance(obj, complex):
                return _jcomplex(obj.real, obj.imag)
            return obj

    if dtype is None:
        dtype = _getdtypefromobj(obj)
    else:
        dtype = _translatenativetype(dtype)

    return _df.createFromObject(obj, dtype.value)
示例#3
0
def __cvt_jobj(obj, dtype=None, copy=True, force=False):
    '''Convert object to java object'''
    if isinstance(obj, ndarray):
        obj = obj._jdataset()

    if isinstance(obj, _ds):
        if copy:
            if dtype is None or _translatenativetype(dtype).value == obj.dtype:
                return obj.clone()
            else:
                return obj.cast(_translatenativetype(dtype).value)
        else:
            if dtype is None:
                return obj
            return obj.cast(_translatenativetype(dtype).value)

    if not isinstance(obj, list):
        if isinstance(obj, _matrix):  # cope with JAMA matrices
            if dtype is None:
                dtype = float64
            obj = obj.getArray()

    obj = _cvt2j(obj)
    try:
        iter(obj)
    except:
        if not force:
            if isinstance(obj, complex):
                return _jcomplex(obj.real, obj.imag)
            return obj

    if dtype is None:
        dtype = _getdtypefromobj(obj)
    else:
        dtype = _translatenativetype(dtype)

    return _df.createFromObject(obj, dtype.value)
示例#4
0
    def __setitem__(self, key, value):
        value = fromDS(value)
        if isinstance(value, ndarray):
            value = value._jdataset()
        else:
            value = _cvt2j(value)

        isslice, key = _toslice(self.ndim, key)

        try:
            if not isslice:
                if isinstance(key, _booleands):
                    return self.__dataset.setByBoolean(value, key)
                if isinstance(key, _integerds):
                    return self.__dataset.setBy1DIndex(value, key)
                if isinstance(key, (tuple, list)):
                    if len(key) > 0 and isinstance(key[0], _integerds):
                        return self.__dataset.setByIndexes(value, key)
                return self.__dataset.set(value, key)
    
            _setslice(self.__dataset, value, key)
            return self
        except _jarrayindex_exception:
            raise IndexError
示例#5
0
    def __setitem__(self, key, value):
        value = fromDS(value)
        if isinstance(value, ndarray):
            value = value._jdataset()
        else:
            value = _cvt2j(value)

        isslice, key = _toslice(self.ndim, key)

        try:
            if not isslice:
                if isinstance(key, _booleands):
                    return self.__dataset.setByBoolean(value, key)
                if isinstance(key, _integerds):
                    return self.__dataset.setBy1DIndex(value, key)
                if isinstance(key, (tuple, list)):
                    if len(key) > 0 and isinstance(key[0], _integerds):
                        return self.__dataset.setByIndexes(value, key)
                return self.__dataset.set(value, key)

            _setslice(self.__dataset, value, key)
            return self
        except _jarrayindex_exception:
            raise IndexError
示例#6
0
 def fill(self, value):
     self.__dataset.fill(_cvt2j(value))
     return self
示例#7
0
 def fill(self, value):
     self.__dataset.fill(_cvt2j(value))
     return self