示例#1
0
 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,:,:])) 
示例#2
0
 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)
示例#3
0
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)
示例#4
0
 def number_of_dimensions(self):
     return indexing.number_of_dimensions_after_index(self._original_set().number_of_dimensions(), self._private.indices)
示例#5
0
 def number_of_dimensions(self):
     return indexing.number_of_dimensions_after_index(self._original_set().number_of_dimensions(), self._private.indices)
示例#6
0
 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)
示例#7
0
文件: grids.py 项目: Ingwar/amuse
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)