(self, index)
return GPUArray(
            shape=tuple(new_shape),
            dtype=self.dtype,
            allocator=self.allocator,
            base=self,
            gpudata=int(self.gpudata) + new_offset,
            strides=tuple(new_strides),
        )
.. versionadded:: 2013.1
.. versionadded:: 2013.1
.. versionadded :: 2013 . 1
def __getitem__(self, index):
        """
        .. versionadded:: 2013.1
        """
        if not isinstance(index, tuple):
            index = (index,)

        new_shape = []
        new_offset = 0
        new_strides = []

        seen_ellipsis = False

        index_axis = 0
        array_axis = 0
        while index_axis < len(index):
            index_entry = index[index_axis]

            if array_axis > len(self.shape):
                raise IndexError("too many axes in index")

            if isinstance(index_entry, slice):
                start, stop, idx_stride = index_entry.indices(self.shape[array_axis])

                array_stride = self.strides[array_axis]

                new_shape.append((abs(stop - start) - 1) // abs(idx_stride) + 1)
                new_strides.append(idx_stride * array_stride)
                new_offset += array_stride * start

                index_axis += 1
                array_axis += 1

            elif isinstance(index_entry, (int, np.integer)):
                array_shape = self.shape[array_axis]
                if index_entry < 0:
                    index_entry += array_shape

                if not (0 <= index_entry < array_shape):
                    raise IndexError("subindex in axis %d out of range" % index_axis)

                new_offset += self.strides[array_axis] * index_entry

                index_axis += 1
                array_axis += 1

            elif index_entry is Ellipsis:
                index_axis += 1

                remaining_index_count = len(index) - index_axis
                new_array_axis = len(self.shape) - remaining_index_count
                if new_array_axis < array_axis:
                    raise IndexError("invalid use of ellipsis in index")
                while array_axis < new_array_axis:
                    new_shape.append(self.shape[array_axis])
                    new_strides.append(self.strides[array_axis])
                    array_axis += 1

                if seen_ellipsis:
                    raise IndexError("more than one ellipsis not allowed in index")
                seen_ellipsis = True

            elif index_entry is np.newaxis:
                new_shape.append(1)
                new_strides.append(0)
                index_axis += 1

            else:
                raise IndexError("invalid subindex in axis %d" % index_axis)

        while array_axis < len(self.shape):
            new_shape.append(self.shape[array_axis])
            new_strides.append(self.strides[array_axis])

            array_axis += 1

        return GPUArray(
            shape=tuple(new_shape),
            dtype=self.dtype,
            allocator=self.allocator,
            base=self,
            gpudata=int(self.gpudata) + new_offset,
            strides=tuple(new_strides),
        )
def __getitem__ ( self , index ) : if not isinstance ( index , tuple ) : index = ( index , ) new_shape = [ ] new_offset = 0 new_strides = [ ] seen_ellipsis = False index_axis = 0 array_axis = 0 while index_axis < len ( index ) : index_entry = index [ index_axis ] if array_axis > len ( self . shape ) : raise IndexError ( "too many axes in index" ) if isinstance ( index_entry , slice ) : start , stop , idx_stride = index_entry . indices ( self . shape [ array_axis ] ) array_stride = self . strides [ array_axis ] new_shape . append ( ( abs ( stop - start ) - 1 ) // abs ( idx_stride ) + 1 ) new_strides . append ( idx_stride * array_stride ) new_offset += array_stride * start index_axis += 1 array_axis += 1 elif isinstance ( index_entry , ( int , np . integer ) ) : array_shape = self . shape [ array_axis ] if index_entry < 0 : index_entry += array_shape if not ( 0 <= index_entry < array_shape ) : raise IndexError ( "subindex in axis %d out of range" % index_axis ) new_offset += self . strides [ array_axis ] * index_entry index_axis += 1 array_axis += 1 elif index_entry is Ellipsis : index_axis += 1 remaining_index_count = len ( index ) - index_axis new_array_axis = len ( self . shape ) - remaining_index_count if new_array_axis < array_axis : raise IndexError ( "invalid use of ellipsis in index" ) while array_axis < new_array_axis : new_shape . append ( self . shape [ array_axis ] ) new_strides . append ( self . strides [ array_axis ] ) array_axis += 1 if seen_ellipsis : raise IndexError ( "more than one ellipsis not allowed in index" ) seen_ellipsis = True elif index_entry is np . newaxis : new_shape . append ( 1 ) new_strides . append ( 0 ) index_axis += 1 else : raise IndexError ( "invalid subindex in axis %d" % index_axis ) while array_axis < len ( self . shape ) : new_shape . append ( self . shape [ array_axis ] ) new_strides . append ( self . strides [ array_axis ] ) array_axis += 1 return GPUArray ( shape = tuple ( new_shape ) , dtype = self . dtype , allocator = self . allocator , base = self , gpudata = int ( self . gpudata ) + new_offset , strides = tuple ( new_strides ) , )