Ejemplo n.º 1
0
    def testIndexTricks(self):
        mgrid = nd_grid()
        g = mgrid[0:5, 0:5]
        g.tiles()  # tilesable means no loop exists

        ogrid = nd_grid(sparse=True)
        o = ogrid[0:5, 0:5]
        [ob.tiles() for ob in o]  # tilesable means no loop exists
Ejemplo n.º 2
0
    def testIndexTrickExecution(self):
        mgrid = nd_grid()
        t = mgrid[0:5, 0:5]

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.lib.index_tricks.nd_grid()[0:5, 0:5]
        np.testing.assert_equal(res, expected)

        t = mgrid[-1:1:5j]

        res = self.executor.execute_tensor(t, concat=True)[0]
        expected = np.lib.index_tricks.nd_grid()[-1:1:5j]
        np.testing.assert_equal(res, expected)

        ogrid = nd_grid(sparse=True)

        t = ogrid[0:5, 0:5]

        res = [self.executor.execute_tensor(o, concat=True)[0] for o in t]
        expected = np.lib.index_tricks.nd_grid(sparse=True)[0:5, 0:5]
        [np.testing.assert_equal(r, e) for r, e in zip(res, expected)]