Changeset 3014


Ignore:
Timestamp:
May 30, 2006, 11:57:08 AM (18 years ago)
Author:
duncan
Message:

produce a warning if vertices without triangles are in the input.

Location:
inundation/fit_interpolate
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inundation/fit_interpolate/fit.py

    r3013 r3014  
    3333import exceptions
    3434class ToFewPointsError(exceptions.Exception): pass
     35class VertsWithNoTrianglesError(exceptions.Exception): pass
    3536
    3637DEFAULT_ALPHA = 0.001
     
    305306            self.build_fit_subset(point_coordinates, z, verbose)
    306307
    307         #FIXME: Move this down
    308308        #Check sanity
    309309        m = self.mesh.coordinates.shape[0] #Nbr of basis functions (1/vertex)
     
    319319        self._build_coefficient_matrix_B(verbose)
    320320        loners = self.mesh.get_lone_vertices()
    321         # FIXME  - finish this.
    322         #if len(loners)>0:
    323         #    msg = 'ERROR (least_squares): Too few data points\n'
    324         #    msg += 'There are only %d data points and alpha == 0. ' %n
    325         #    msg += 'Need at least %d\n' %m
    326         #    msg += 'Alternatively, set smoothing parameter alpha to a small '
    327         #    msg += 'positive value,\ne.g. 1.0e-3.'
    328         #    raise ToFewPointsError(msg)
     321        # FIXME  - make this as error message.
     322        # test with
     323        # Not_yet_test_smooth_att_to_mesh_with_excess_verts.
     324        if len(loners)>0:
     325            msg = 'WARNING: (least_squares): \nVertices with no triangles\n'
     326            msg += 'All vertices should be part of a triangle.\n'
     327            msg += 'In the future this will be inforced.\n'
     328            msg += 'The following vertices are not;\n'
     329            msg += str(loners)
     330            print msg
     331            #raise VertsWithNoTrianglesError(msg)
    329332       
    330333       
  • inundation/fit_interpolate/test_fit.py

    r3012 r3014  
    805805
    806806
    807     def test_smooth_att_to_mesh_with_excess_verts(self):
     807    def Not_yet_test_smooth_att_to_mesh_with_excess_verts(self):
    808808
    809809        a = [0.0, 0.0]
     
    827827
    828828        interp = Fit(points, triangles, alpha=0.0)
    829         f = interp.fit(data_coords, z)
    830         answer = linear_function(points)
     829       
     830        try:
     831            f = interp.fit(data_coords, z)
     832        except VertsWithNoTrianglesError:
     833            pass
     834        else:
     835            raise 'Verts with no triangles did not raise error!'
     836       
     837        #f = interp.fit(data_coords, z)
     838        #answer = linear_function(points)
    831839
    832840        #  Removing the bad verts that we don't care about
    833         f = f[0:3]
    834         answer = answer[0:3]
    835 
    836         #print "f\n",f
    837         #print "answer\n",answer
    838 
    839         assert allclose(f, answer)
    840         # Note: This test is iffy. Fit can fail if lone verts are inputted.
     841        #f = f[0:3]
     842        #answer = answer[0:3]
     843        #assert allclose(f, answer)
    841844
    842845#-------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.