コード例 #1
0
    def __getitem__(self, key):
        data = self._getdata()
        if isinstance(data, _ldataset):
            isslice,key = self._toslice(key)
            if not isslice: # single item
                key = tuple([ slice(k,k+1) for k in key ])
                v = _getslice(data, key)
                v = v.getAbs(0)
            else:
                v = _getslice(data, key)
            return v

        return data[key]
コード例 #2
0
ファイル: jyhdf5io.py プロジェクト: DawnScience/scisoft-core
    def __getitem__(self, key):
        data = self._getdata()
        if isinstance(data, _ldataset):
            isslice, key = _toslice(self.rank, key)
            if not isslice: # single item
                key = tuple([ slice(k,k+1) for k in asIterable(key) ])
                v = _getslice(data, key)
                v = v.getAbs(0)
            else:
                v = _getslice(data, key)
            return v

        return asarray(data)[key]
コード例 #3
0
    def __getitem__(self, key):
        data = self._getdata()
        if isinstance(data, _ldataset):
            isslice, key = _toslice(self.rank, key)
            if not isslice:  # single item
                key = tuple([slice(k, k + 1) for k in key])
                v = _getslice(data, key)
                v = v.getAbs(0)
            else:
                v = _getslice(data, key)
            return v

        return asarray(data)[key]
コード例 #4
0
    def __getitem__(self, key):
        if isinstance(key, ndarray):
            key = key._jdataset()
            if isinstance(key, _booleands):
                return self.__dataset.getByBoolean(key)
            if isinstance(key, _integerds):
                return self.__dataset.getByIndex(key)
# FIXME add integers indexing
        isslice, key = self._toslice(key)
        try:
            if isslice:
                return _getslice(self.__dataset, key)
            return self.__dataset.getObject(key)
        except _jarrayindex_exception:
            raise IndexError
コード例 #5
0
    def __getitem__(self, key):
# FIXME add advanced integers indexing
        isslice, key = _toslice(self.ndim, key)
        try:
            if not isslice:
                if isinstance(key, _booleands):
                    return self.__dataset.getByBoolean(key)
                if isinstance(key, _integerds):
                    return self.__dataset.getBy1DIndex(key)
                if isinstance(key, (tuple, list)):
                    if len(key) > 0 and isinstance(key[0], _integerds):
                        return self.__dataset.getByIndexes(key)
                return self.__dataset.getObject(key)
    
            return _getslice(self.__dataset, key)
        except _jarrayindex_exception:
            raise IndexError
コード例 #6
0
ファイル: jycore.py プロジェクト: flucke/scisoft-core
    def __getitem__(self, key):
        # FIXME add advanced integers indexing
        isslice, key = _toslice(self.ndim, key)
        try:
            if not isslice:
                if isinstance(key, _booleands):
                    return self.__dataset.getByBoolean(key)
                if isinstance(key, _integerds):
                    return self.__dataset.getBy1DIndex(key)
                if isinstance(key, (tuple, list)):
                    if len(key) > 0 and isinstance(key[0], _integerds):
                        return self.__dataset.getByIndexes(key)
                return self.__dataset.getObject(key)

            return _getslice(self.__dataset, key)
        except _jarrayindex_exception:
            raise IndexError
コード例 #7
0
def ravel_multi_index(multi_index, dims, mode='raise'):
    '''Converts a tuple of coordinate arrays to an array of flat indexes
    '''
    if isinstance(mode, tuple):
        mode = [_prep_mode.get(m, -1) for m in mode]
    else:
        mode = _prep_mode.get(mode, -1)

    if isinstance(multi_index, _ds): # split single array
        multi_index = [ _getslice(multi_index, i) for i in range(multi_index.shape[0]) ]

    single = False
    if isinstance(multi_index[0], int):
        single = True
        multi_index = [ array(m)._jdataset() for m in multi_index ]


    pos = _dsutils.calcIndexesFromPositions(multi_index, dims, mode)
    if single:
        return pos.getObject([])
    return pos
コード例 #8
0
ファイル: jycore.py プロジェクト: flucke/scisoft-core
def ravel_multi_index(multi_index, dims, mode='raise'):
    '''Converts a tuple of coordinate arrays to an array of flat indexes
    '''
    if isinstance(mode, tuple):
        mode = [_prep_mode.get(m, -1) for m in mode]
    else:
        mode = _prep_mode.get(mode, -1)

    if isinstance(multi_index, _ds):  # split single array
        multi_index = [
            _getslice(multi_index, i) for i in range(multi_index.shape[0])
        ]

    single = False
    if isinstance(multi_index[0], int):
        single = True
        multi_index = [array(m)._jdataset() for m in multi_index]

    pos = _dsutils.calcIndexesFromPositions(multi_index, dims, mode)
    if single:
        return pos.getObject([])
    return pos