Ejemplo n.º 1
0
    def test_retrieve_from_10d_grid(self):
        shape = tuple([2] * 10)
        grid = MultiDimensionalGrid(grid_shape=shape)
        a = np.arange(2**10).reshape(shape).tolist()
        grid.set_grid(a)

        self.assert_all_retrievals_are_correct(grid, a, shape)
Ejemplo n.º 2
0
    def test_retrieve_from_2d_grid(self):
        grid = MultiDimensionalGrid(grid_shape=(2, 3))

        a = [[1, 2, 3], [4, 5, 6]]
        grid.set_grid(a)

        self.assertEqual(4, grid.get_item((1, 0)))
        self.assertEqual(3, grid.get_item((0, 2)))
Ejemplo n.º 3
0
    def test_all_retrievals_from_1d_grid_return_correct_items(self):
        grid = MultiDimensionalGrid(grid_shape=(3, ))

        a = [1, 2, 3]
        grid.set_grid(a)

        for i in range(3):
            self.assertEqual(a[i], grid.get_item((i, )))
Ejemplo n.º 4
0
    def test_all_retrievals_from_3d_grid_return_correct_items(self):
        shape = (5, 3, 2)
        grid = MultiDimensionalGrid(grid_shape=shape)

        a = np.arange(5 * 3 * 2).reshape(shape).tolist()
        grid.set_grid(a)

        self.assert_all_retrievals_are_correct(grid, a, shape)
Ejemplo n.º 5
0
    def test_all_retrievals_from_2d_grid_return_correct_items(self):
        grid = MultiDimensionalGrid(grid_shape=(2, 3))

        a = [[1, 2, 3], [4, 5, 6]]
        grid.set_grid(a)

        for i in range(2):
            for j in range(3):
                self.assertEqual(a[i][j], grid.get_item((i, j)))
Ejemplo n.º 6
0
    def test_1d(self):
        grid = MultiDimensionalGrid(grid_shape=(3, ))
        grid.set_grid([1, 2, 3])

        self.assertEqual(2, grid.get_item((1, )))