Changeset 2666 for inundation/pyvolution/test_least_squares.py
- Timestamp:
- Apr 6, 2006, 11:07:20 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/test_least_squares.py
r2665 r2666 1856 1856 #Fit surface to mesh 1857 1857 z = linear_function(data_points1) #Example z-values 1858 v = fit_to_mesh(points, triangles, data_points1, z, alpha=0.0, 1859 precrop=True, verbose=False) 1858 v = fit_to_mesh(points, triangles, data_points1, z, alpha=0.0, 1859 precrop=True, verbose=False) 1860 1860 1861 assert allclose(linear_function(points), v) 1862 1863 1864 1865 def test_acceptable_overshoot(self): 1866 """Fit a surface to one set of points. Then interpolate that surface 1867 using another set of points. 1868 Check that exceedance in fitted values are caught. 1869 """ 1870 from mesh import Mesh 1871 1872 1873 #Setup mesh used to represent fitted function 1874 a = [0.0, 0.0] 1875 b = [0.0, 2.0] 1876 c = [2.0, 0.0] 1877 d = [0.0, 4.0] 1878 e = [2.0, 2.0] 1879 f = [4.0, 0.0] 1880 1881 points = [a, b, c, d, e, f] 1882 #bac, bce, ecf, dbe, daf, dae 1883 triangles = [[1,0,2], [1,2,4], [4,2,5], [3,1,4]] 1884 1885 #Datapoints to fit from 1886 data_points1 = [[ 0.66666667, 0.66666667], 1887 [ 1.33333333, 1.33333333], 1888 [ 2.66666667, 0.66666667], 1889 [ 0.66666667, 2.66666667], 1890 [ 0.0, 1.0], 1891 [ 0.0, 3.0], 1892 [ 1.0, 0.0], 1893 [ 1.0, 1.0], 1894 [ 15, -17], #Outside mesh 1895 [ 1.0, 2.0], 1896 [ 1.0, 3.0], 1897 [ 2.0, 1.0], 1898 [ 3.0, 0.0], 1899 [ 3.0, 1.0]] 1900 1901 #Fit surface to mesh 1902 z = linear_function(data_points1) #Example z-values 1903 1904 try: 1905 v = fit_to_mesh(points, triangles, data_points1, z, alpha=0.0, 1906 acceptable_overshoot = 0.2, 1907 precrop=True, verbose=False) 1908 except FittingError, e: 1909 pass 1910 else: 1911 raise 'Should have raised exception' 1912 1913 1914 #assert allclose(linear_function(points), v) 1915 1861 1916 1862 1917 … … 1864 1919 if __name__ == "__main__": 1865 1920 #suite = unittest.makeSuite(Test_Least_Squares,'test_smooth_attributes_to_mesh_function') 1866 suite = unittest.makeSuite(Test_Least_Squares,'test _fit_using_fit_to_mesh')1921 suite = unittest.makeSuite(Test_Least_Squares,'test') 1867 1922 1868 1923 #suite = unittest.makeSuite(Test_Least_Squares,'test_fit_to_msh_netcdf_fileII')
Note: See TracChangeset
for help on using the changeset viewer.