Exemple #1
0
 def test_indexing_basic(self):
     for x in xrange(self.Nx):
         for y in xrange(self.Ny):
             i = utils.xy2index(self.shape, x, y)
             assert (x, y) == utils.index2xy(self.shape, i)
             assert i == utils.xy2index(self.shape,
                                        *utils.index2xy(self.shape, i))
Exemple #2
0
    def test_indexing_grid(self):
        xgrid = np.zeros(self.shape) + np.arange(self.Nx)[:, None]
        ygrid = np.zeros(self.shape) + np.arange(self.Ny)[None, :]

        i1 = utils.xy2index(self.shape, xgrid, ygrid).astype(int)
        i2 = np.arange(self.Nx * self.Ny).reshape(self.shape)
        assert np.all(i1 == i2)

        x1, y1 = utils.index2xy(self.shape, i1)
        assert np.all(x1 == xgrid) and np.all(y1 == ygrid)
Exemple #3
0
    def test_indexing_grid(self):
        xgrid = np.zeros(self.shape) + np.arange(self.Nx)[:, None]
        ygrid = np.zeros(self.shape) + np.arange(self.Ny)[None, :]

        i1 = utils.xy2index(self.shape, xgrid, ygrid).astype(int)
        i2 = np.arange(self.Nx * self.Ny).reshape(self.shape)
        assert np.all(i1 == i2)

        x1, y1 = utils.index2xy(self.shape, i1)
        assert np.all(x1 == xgrid) and np.all(y1 == ygrid)
Exemple #4
0
 def test_indexing_basic(self):
     for x in xrange(self.Nx):
         for y in xrange(self.Ny):
             i = utils.xy2index(self.shape, x, y)
             assert (x, y) == utils.index2xy(self.shape, i)
             assert i == utils.xy2index(self.shape, *utils.index2xy(self.shape, i))