def test_XY(self): """A diagonal section""" grd = MyGrid() i0, j0 = 14, 4 i1, j1 = 17, 7 sec = linear_section(i0, i1, j0, j1, grd) self.assertTrue(np.all(sec.X == np.array([14, 15, 16, 17]))) self.assertTrue(np.all(sec.Y == np.array([4, 5, 6, 7])))
def test_X(self): """A section in the X direction""" grd = MyGrid() i0, j0 = 14, 4 i1, j1 = 17, 4 sec = linear_section(i0, i1, j0, j1, grd) self.assertTrue(np.all(sec.X == np.array([14, 15, 16, 17]))) self.assertTrue(np.all(sec.Y == np.array([4, 4, 4, 4])))
def test_Y(self): """A section in the Y direction""" grd = MyGrid() i0, j0 = 14, 4 i1, j1 = 14, 7 sec = linear_section(i0, i1, j0, j1, grd) self.assertTrue(np.all(sec.X == np.array([14, 14, 14, 14]))) self.assertTrue(np.all(sec.Y == np.array([4, 5, 6, 7])))
def test_Yminus(self): """Skew section, negative Y direction""" grd = MyGrid() i0, j0 = 15, 7 i1, j1 = 14, 4 sec = linear_section(i0, i1, j0, j1, grd) self.assertTrue(np.allclose(sec.X, np.array([15, 14.67, 14.33, 14]), atol=0.005)) self.assertTrue(np.all(sec.Y == np.array([7, 6, 5, 4])))
def test_Xminus(self): """Skew section, negative X direction""" grd = MyGrid() i0, j0 = 17, 4 i1, j1 = 14, 5 sec = linear_section(i0, i1, j0, j1, grd) self.assertTrue(np.all(sec.X == np.array([17, 16, 15, 14]))) self.assertTrue(np.allclose(sec.Y, np.array([4, 4.33, 4.67, 5]), atol=0.005))