def test1(self): self.assertEquals(2, number_of_dimensions_after_index(3, 1)) self.assertEquals(3, number_of_dimensions_after_index(3, numpy.s_[0:3])) self.assertEquals(1, number_of_dimensions_after_index(3, combine_indices(3,2))) self.assertEquals(0, number_of_dimensions_after_index(3, combine_indices(combine_indices(3,2),1))) self.assertEquals(3, indexing.number_of_dimensions_after_index(3, numpy.s_[1:2,...,...])) self.assertEquals(3, indexing.number_of_dimensions_after_index(3, numpy.s_[1:2,:,:]))
def __getitem__(self, index): normalized_index= indexing.normalize_slices(self.shape,index) combined_index = indexing.combine_indices(self._private.indices, normalized_index) if indexing.number_of_dimensions_after_index(self._original_set().number_of_dimensions(), combined_index) == 0: return GridPoint(combined_index, self._original_set()) else: return SubGrid(self._original_set(), combined_index)
def new_subgrid_from_index(grid, index): if indexing.number_of_dimensions_after_index(grid.number_of_dimensions(), index) == 0: return GridPoint(index, grid) else: return SubGrid(grid, index)
def number_of_dimensions(self): return indexing.number_of_dimensions_after_index(self._original_set().number_of_dimensions(), self._private.indices)
def __getitem__(self, index): if indexing.number_of_dimensions_after_index(self.number_of_dimensions(), index) == 0: return GridPoint(index, self) else: return SubGrid(self, index)