예제 #1
0
    def test_get_block_1(self):
        a = ChunkGrid(2, int, 0)
        expected = np.zeros((6, 6, 6), dtype=int)
        for n, i in enumerate(np.ndindex(6, 6, 6)):
            pos = np.array(i, dtype=int) - 2
            a.set_value(pos, n + 1)
            expected[i] = n + 1

        block = a.get_block_at((0, 0, 0), (3, 3, 3), corners=True, edges=True)
        self.assertEqual(str(expected), str(a.block_to_array(block)))
예제 #2
0
    def test_get_block_2(self):
        a = ChunkGrid(2, int, 0)
        expected = np.zeros((6, 6, 6), dtype=int)
        for n, i in enumerate(np.ndindex(6, 6, 6)):
            pos = np.array(i, dtype=int) - 2
            a.set_value(pos, n + 1)
            s = np.sum(pos < 0) + np.sum(2 <= pos)
            if s >= 2:
                continue
            expected[i] = n + 1

        block = a.get_block_at((0, 0, 0), (3, 3, 3), corners=False, edges=False)
        self.assertEqual(str(expected), str(a.block_to_array(block)))