- Timestamp:
- Mar 3, 2005, 6:40:01 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/test_least_squares.py
r994 r997 301 301 assert allclose(sum(interp.get_A(), axis=1), 1.0) 302 302 303 304 # this causes a memory error in scipy.sparce 303 def test_arbitrary_datapoints_some_outside(self): 304 """Try arbitrary datapoints one outside the triangle. 305 That one should be ignored 306 """ 307 308 from Numeric import sum 309 310 a = [0.0, 0.0] 311 b = [0.0, 2.0] 312 c = [2.0,0.0] 313 points = [a, b, c] 314 vertices = [ [1,0,2] ] #bac 315 316 data = [ [0.2, 1.5], [0.123, 1.768], [1.43, 0.44], [5.0, 7.0]] 317 318 319 interp = Interpolation(points, vertices, data, precrop = True) 320 assert allclose(sum(interp.get_A(), axis=1), 1.0) 321 322 interp = Interpolation(points, vertices, data, precrop = False) 323 assert allclose(sum(interp.get_A(), axis=1), [1,1,1,0]) 324 325 326 327 # this causes a memory error in scipy.sparse 305 328 def test_more_triangles(self): 306 329 … … 844 867 [ 1.0, 0.0], 845 868 [ 1.0, 1.0], 869 [ 15, -17], #Outside mesh 846 870 [ 1.0, 2.0], 847 871 [ 1.0, 3.0], … … 851 875 852 876 #Fit surface to mesh 853 interp = Interpolation(points, triangles, data_points1, alpha=0.0) 877 interp = Interpolation(points, triangles, data_points1, alpha=0.0, 878 precrop = True) 854 879 z = linear_function(data_points1) #Example z-values 855 880 f = interp.fit(z) #Fitted values at vertices … … 861 886 [ 0.5, 0.5], 862 887 [ 0.7, 0.7], 888 [-13, 65], #Outside 863 889 [ 1.0, 0.5], 864 890 [ 2.0, 0.4], … … 866 892 867 893 868 #Build new A matrix based on new points 869 interp.build_interpolation_matrix_A(data_points2) 894 895 #Build new A matrix based on new points (without precrop) 896 interp.build_interpolation_matrix_A(data_points2, precrop = False) 870 897 871 898 #Interpolate using fitted surface 872 899 z1 = interp.interpolate(f) 900 901 #import Numeric 902 #data_points2 = Numeric.take(data_points2, interp.point_indices) 903 904 #Desired result (OK for points inside) 905 906 answer = linear_function(data_points2) 907 import Numeric 908 z1 = Numeric.take(z1, [0,1,2,4,5,6]) 909 answer = Numeric.take(answer, [0,1,2,4,5,6]) 910 assert allclose(z1, answer) 911 912 #Build new A matrix based on new points (with precrop) 913 interp.build_interpolation_matrix_A(data_points2, precrop = True) 914 915 #Interpolate using fitted surface 916 z1 = interp.interpolate(f) 917 918 import Numeric 919 data_points2 = Numeric.take(data_points2, interp.point_indices) 873 920 874 921 #Desired result … … 1112 1159 #------------------------------------------------------------- 1113 1160 if __name__ == "__main__": 1114 #suite = unittest.makeSuite(TestCase,'test')1115 1116 1161 suite = unittest.makeSuite(TestCase,'test') 1162 1117 1163 #suite = unittest.makeSuite(TestCase,'test_arbitrary_datapoints') 1118 1164 runner = unittest.TextTestRunner(verbosity=1)
Note: See TracChangeset
for help on using the changeset viewer.