def test_element_sum(self): dv = DoubleVector() iv = IntVector() for i in range(10): dv.append(i + 1) iv.append(i + 1) self.assertEqual(dv.elementSum(), 55) self.assertEqual(iv.elementSum(), 55)
def test_element_sum(self): dv = DoubleVector() iv = IntVector() for i in range(10): dv.append(i + 1) iv.append(i + 1) self.assertEqual(dv.elementSum(), 55) self.assertEqual(iv.elementSum(), 55)
def center(self): xlist = DoubleVector() ylist = DoubleVector() for segment in self: C1 = segment.getC1() C2 = segment.getC2() (J1, I1) = divmod(C1, self.__grid.getNX() + 1) (J2, I2) = divmod(C2, self.__grid.getNX() + 1) (x1, y1, z) = self.__grid.getNodePos(I1, J1, self.__k) (x2, y2, z) = self.__grid.getNodePos(I2, J2, self.__k) xlist.append(x1) xlist.append(x2) ylist.append(y1) ylist.append(y2) N = len(xlist) return (xlist.elementSum() / N, ylist.elementSum() / N)
def center(self): xlist = DoubleVector() ylist = DoubleVector() for segment in self: C1 = segment.getC1() C2 = segment.getC2() (J1, I1) = divmod(C1, self.__grid.getNX() + 1) (J2, I2) = divmod(C2, self.__grid.getNX() + 1) (x1,y1,z) = self.__grid.getNodePos(I1, J1, self.__k) (x2,y2,z) = self.__grid.getNodePos(I2, J2, self.__k) xlist.append(x1) xlist.append(x2) ylist.append(y1) ylist.append(y2) N = len(xlist) return (xlist.elementSum()/N, ylist.elementSum()/N)