Пример #1
0
 def test17(self):
     a = numpy.arange(6).reshape(2,3)
     indices = numpy.asarray([True,False])
     direct =  a[indices, 1:][0,1:]
     combined = combine_indices(indexing.normalize_slices(a.shape,numpy.s_[indices,1:]),
         indexing.normalize_slices(a[indices,1:].shape,numpy.s_[0,1:]))
     indirect = a[combined]
     self.assertEquals(indirect, direct)
Пример #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 test4(self):
     a = numpy.arange(12).reshape(3, 4)
     direct = a[1][:]
     indirect = a[combine_indices(
         1, indexing.normalize_slices(a[1].shape, numpy.s_[:]))]
     self.assertEqual(indirect.shape, direct.shape)
     self.assertTrue(numpy.all(indirect == direct))
Пример #4
0
 def __init__(self, grid, indices):
     AbstractGrid.__init__(self, grid)
     
     self._private.previous=None
     self._private.grid = grid
     self._private.indices = indexing.normalize_slices(grid.shape,indices)
     self._private.collection_attributes=grid.collection_attributes
Пример #5
0
 def get_values_in_store(self, indices, attributes, by_key=True):
     normalized_indices = indexing.normalize_slices(self.shape, indices)
     combined_index = indexing.combine_indices(self._private.indices,
                                               normalized_indices)
     result = self._private.grid.get_values_in_store(
         combined_index, attributes)
     return result
Пример #6
0
 def test7(self):
     a = numpy.arange(30).reshape(6, 5)
     direct = a[1:5:2][1:]
     indirect = a[combine_indices(
         numpy.s_[1:5:2],
         indexing.normalize_slices(a[1:5:2].shape, numpy.s_[1:]))]
     self.assertEqual(indirect.shape, direct.shape)
     self.assertTrue(numpy.all(indirect == direct))
Пример #7
0
 def test9(self):
     a = numpy.arange(100)
     for s in range(0,40):
         for e in range(40,101):
             for step in range(1,5):
                 direct =  a[s:e:step][1:5:2]
                 indirect = a[combine_indices(numpy.s_[s:e:step], 
                   indexing.normalize_slices(a[s:e:step].shape,numpy.s_[1:5:2]))]
                 self.assertEquals(indirect.shape, direct.shape)
                 self.assertTrue(numpy.all(indirect ==  direct))
Пример #8
0
 def set_values_in_store_async(self,
                               indices,
                               attributes,
                               values,
                               by_key=True):
     normalized_indices = indexing.normalize_slices(self.shape, indices)
     combined_index = indexing.combine_indices(self._private.indices,
                                               normalized_indices)
     return self._private.grid.set_values_in_store_async(
         combined_index, attributes, values)
Пример #9
0
 def test7(self):
     a = numpy.arange(30).reshape(6,5)
     direct =  a[1:5:2][1:]
     indirect = a[combine_indices(numpy.s_[1:5:2],indexing.normalize_slices(a[1:5:2].shape,numpy.s_[1:]))]
     self.assertEquals(indirect.shape, direct.shape)
     self.assertTrue(numpy.all(indirect ==  direct))
Пример #10
0
 def test5(self):
     a = numpy.arange(12).reshape(3,4)
     direct =  a[0:2][:]
     indirect = a[combine_indices(numpy.s_[0:2],indexing.normalize_slices(a[0:2].shape,numpy.s_[:]))]
     self.assertEquals(indirect.shape, direct.shape)
     self.assertTrue(numpy.all(indirect ==  direct))
Пример #11
0
 def __getitem__(self, index):
     normalized_index= indexing.normalize_slices(self.shape,index)
     combined_index = indexing.combine_indices(self._private.indices, normalized_index)
     return new_subgrid_from_index(self._original_set(), combined_index)
Пример #12
0
 def set_values_in_store_async(self, indices, attributes, values, by_key = True):
     normalized_indices = indexing.normalize_slices(self.shape,indices)
     combined_index = indexing.combine_indices(self._private.indices, normalized_indices)
     return self._private.grid.set_values_in_store_async(combined_index, attributes, values)
Пример #13
0
 def get_values_in_store(self, indices, attributes, by_key = True):
     normalized_indices = indexing.normalize_slices(self.shape,indices)
     combined_index = indexing.combine_indices(self._private.indices, normalized_indices)
     result = self._private.grid.get_values_in_store(combined_index, attributes)
     return result
Пример #14
0
 def __init__(self, grid, indices):
     AbstractGrid.__init__(self, grid)
     
     self._private.grid = grid
     self._private.indices = indexing.normalize_slices(grid.shape,indices)
Пример #15
0
 def __getitem__(self, index):
     normalized_index= indexing.normalize_slices(self.shape,index)
     combined_index = indexing.combine_indices(self._private.indices, normalized_index)
     return new_subgrid_from_index(self._original_set(), combined_index)
Пример #16
0
 def __init__(self, grid, indices):
     AbstractGrid.__init__(self, grid)
     
     self._private.grid = grid
     self._private.indices = indexing.normalize_slices(grid.shape,indices)