def test_gradient_C_extension(self): from anuga.utilities.util_ext import gradient as gradient_c x0 = 2.0/3; y0 = 2.0/3 x1= 8.0/3; y1 = 2.0/3 x2 = 2.0/3; y2 = 8.0/3 q0 = 2.0+2.0/3 q1 = 8.0+2.0/3 q2 = 2.0+8.0/3 #Gradient of fitted pwl surface a, b = gradient_c(x0, y0, x1, y1, x2, y2, q0, q1, q2) assert abs(a - 3.0) < epsilon assert abs(b - 1.0) < epsilon
def test_gradient_C_extension(self): from anuga.utilities.util_ext import gradient as gradient_c x0 = 2.0 / 3 y0 = 2.0 / 3 x1 = 8.0 / 3 y1 = 2.0 / 3 x2 = 2.0 / 3 y2 = 8.0 / 3 q0 = 2.0 + 2.0 / 3 q1 = 8.0 + 2.0 / 3 q2 = 2.0 + 8.0 / 3 #Gradient of fitted pwl surface a, b = gradient_c(x0, y0, x1, y1, x2, y2, q0, q1, q2) assert abs(a - 3.0) < epsilon assert abs(b - 1.0) < epsilon
def test_gradient_C_extension3(self): from anuga.utilities.util_ext import gradient as gradient_c seed((17, 53)) x0, x1, x2, y0, y1, y2 = uniform(0.0, 3.0, 6) q0 = uniform(0.0, 10.0, 4) q1 = uniform(1.0, 3.0, 4) q2 = uniform(7.0, 20.0, 4) for i in range(4): #Gradient of fitted pwl surface a_ref, b_ref = gradient_python(x0, y0, x1, y1, x2, y2, q0[i], q1[i], q2[i]) #print a_ref, b_ref a, b = gradient_c(x0, y0, x1, y1, x2, y2, q0[i], q1[i], q2[i]) #print a, a_ref, b, b_ref assert abs(a - a_ref) < epsilon assert abs(b - b_ref) < epsilon
def test_gradient_C_extension3(self): from anuga.utilities.util_ext import gradient as gradient_c seed((17, 53)) x0, x1, x2, y0, y1, y2 = uniform(0.0,3.0,6) q0 = uniform(0.0, 10.0, 4) q1 = uniform(1.0, 3.0, 4) q2 = uniform(7.0, 20.0, 4) for i in range(4): #Gradient of fitted pwl surface a_ref, b_ref = gradient_python(x0, y0, x1, y1, x2, y2, q0[i], q1[i], q2[i]) #print a_ref, b_ref a, b = gradient_c(x0, y0, x1, y1, x2, y2, q0[i], q1[i], q2[i]) #print a, a_ref, b, b_ref assert abs(a - a_ref) < epsilon assert abs(b - b_ref) < epsilon