示例#1
0
    def test_front(self):
        polyline = CPolyline()
        polyline.addPoint(1, 1)
        polyline.addPoint(0, 0, front=True)
        self.assertEqual(len(polyline), 2)

        x, y = polyline[0]
        self.assertEqual(x, 0)
        self.assertEqual(y, 0)

        x, y = polyline[1]
        self.assertEqual(x, 1)
        self.assertEqual(y, 1)
示例#2
0
    def test_item(self):
        polyline = CPolyline()
        polyline.addPoint(10, 20)
        self.assertEqual(len(polyline), 1)

        with self.assertRaises(TypeError):
            (x, y) = polyline["KEY"]

        with self.assertRaises(IndexError):
            (x, y) = polyline[10]

        (x, y) = polyline[0]
        self.assertEqual(x, 10)
        self.assertEqual(y, 20)

        polyline.addPoint(20, 20)
        (x, y) = polyline[-1]
        self.assertEqual(x, 20)
        self.assertEqual(y, 20)
示例#3
0
文件: fault_line.py 项目: pgdr/libecl
 def __init_polyline(self):
     pl = CPolyline()
     for (i,j) in self.getIJPolyline():
         x,y,z = self.__grid.getNodeXYZ(i, j, self.__k)
         pl.addPoint(x, y)
     self.__polyline = pl