Changeset 6441


Ignore:
Timestamp:
Mar 4, 2009, 8:26:22 AM (16 years ago)
Author:
rwilson
Message:

After changes to get_absolute, ensure_numeric, etc.

Location:
branches/numpy/anuga
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • branches/numpy/anuga/abstract_2d_finite_volumes/quantity.py

    r6410 r6441  
    460460
    461461        msg = 'Indices must be a list or None'
    462         assert (type(indices) in [ListType, NoneType]
    463                 or isinstance(indices, num.ndarray)), msg
     462        assert (indices is None
     463                or isinstance(indices, (list, num.ndarray))), msg
    464464
    465465        # Determine which 'set_values_from_...' to use
    466466        if numeric is not None:
    467             if isinstance(numeric, num.ndarray) or isinstance(numeric, list):
     467            if isinstance(numeric, (list, num.ndarray)):
    468468                self.set_values_from_array(numeric, location, indices,
    469469                                           use_cache=use_cache, verbose=verbose)
     
    479479                                                     indices, verbose=verbose,
    480480                                                     use_cache=use_cache)
    481             else:
     481            else:   # see if it's coercible to a float (float, int or long, etc)
    482482                try:
    483483                    numeric = float(numeric)
     
    521521            self.extrapolate_first_order()
    522522
    523 
    524 
    525523    ############################################################################
    526524    # Specific internal functions for setting values based on type
     
    696694    # @param use_cache ??
    697695    # @param verbose True if this method is to be verbose.
    698     def set_values_from_function(self, f,
    699                                        location='vertices',
    700                                        indices=None,
    701                                        use_cache=False,
    702                                        verbose=False):
     696    def set_values_from_function(self,
     697                                 f,
     698                                 location='vertices',
     699                                 indices=None,
     700                                 use_cache=False,
     701                                 verbose=False):
    703702        """Set values for quantity using specified function
    704703
     
    778777    # @param verbose ??
    779778    # @param use_cache ??
    780     def set_values_from_geospatial_data(self, geospatial_data,
    781                                               alpha,
    782                                               location,
    783                                               indices,
    784                                               verbose=False,
    785                                               use_cache=False):
     779    def set_values_from_geospatial_data(self,
     780                                        geospatial_data,
     781                                        alpha,
     782                                        location,
     783                                        indices,
     784                                        verbose=False,
     785                                        use_cache=False):
    786786        """Set values based on geo referenced geospatial data object."""
    787787
     
    835835    # @param verbose True if this method is to be verbose.
    836836    # @param use_cache ??
    837     def set_values_from_points(self, points,
    838                                      values,
    839                                      alpha,
    840                                      location,
    841                                      indices,
    842                                      data_georef=None,
    843                                      verbose=False,
    844                                      use_cache=False):
     837    def set_values_from_points(self,
     838                               points,
     839                               values,
     840                               alpha,
     841                               location,
     842                               indices,
     843                               data_georef=None,
     844                               verbose=False,
     845                               use_cache=False):
    845846        """Set quantity values from arbitray data points using fit_interpolate.fit"""
    846847
     
    857858    # @param use_cache
    858859    # @param max_read_lines
    859     def set_values_from_file(self, filename,
    860                                    attribute_name,
    861                                    alpha,
    862                                    location,
    863                                    indices,
    864                                    verbose=False,
    865                                    use_cache=False,
    866                                    max_read_lines=None):
     860    def set_values_from_file(self,
     861                             filename,
     862                             attribute_name,
     863                             alpha,
     864                             location,
     865                             indices,
     866                             verbose=False,
     867                             use_cache=False,
     868                             max_read_lines=None):
    867869        """Set quantity based on arbitrary points in a points file using
    868870        attribute_name selects name of attribute present in file.
     
    10681070    # @param use_cache ??
    10691071    # @param verbose True if this method is to be verbose.
    1070     def get_interpolated_values(self, interpolation_points,
    1071                                       use_cache=False,
    1072                                       verbose=False):
     1072    def get_interpolated_values(self,
     1073                                interpolation_points,
     1074                                use_cache=False,
     1075                                verbose=False):
    10731076        """Get values at interpolation points
    10741077
     
    11181121    # @param use_cache
    11191122    # @param verbose True if this method is to be verbose.
    1120     def get_values(self, interpolation_points=None,
    1121                          location='vertices',
    1122                          indices=None,
    1123                          use_cache=False,
    1124                          verbose=False):
     1123    def get_values(self,
     1124                   interpolation_points=None,
     1125                   location='vertices',
     1126                   indices=None,
     1127                   use_cache=False,
     1128                   verbose=False):
    11251129        """Get values for quantity
    11261130
     
    12281232    # @param use_cache ??
    12291233    # @param verbose??
    1230     def set_vertex_values(self, A,
    1231                                 indices=None,
    1232                                 use_cache=False,
    1233                                 verbose=False):
     1234    def set_vertex_values(self,
     1235                          A,
     1236                          indices=None,
     1237                          use_cache=False,
     1238                          verbose=False):
    12341239        """Set vertex values for all unique vertices based on input array A
    12351240        which has one entry per unique vertex, i.e. one value for each row in
  • branches/numpy/anuga/abstract_2d_finite_volumes/test_general_mesh.py

    r6428 r6441  
    366366if __name__ == "__main__":
    367367    suite = unittest.makeSuite(Test_General_Mesh, 'test')
    368     #suite = unittest.makeSuite(Test_General_Mesh, 'test_get_vertex_coordinates_with_geo_ref')
    369368    runner = unittest.TextTestRunner()
    370369    runner.run(suite)
  • branches/numpy/anuga/abstract_2d_finite_volumes/test_region.py

    r6410 r6441  
    265265
    266266if __name__ == "__main__":
    267     #suite = unittest.makeSuite(Test_Region, 'test')   
    268     suite = unittest.makeSuite(Test_Region, 'test_unique_vertices_average_loc_vert')   
     267    suite = unittest.makeSuite(Test_Region, 'test')   
    269268    runner = unittest.TextTestRunner()
    270269    runner.run(suite)
  • branches/numpy/anuga/abstract_2d_finite_volumes/util.py

    r6410 r6441  
    476476        if boundary_polygon is not None:
    477477            #removes sts points that do not lie on boundary
    478             #quantities[name] = num.take(quantities[name], gauge_id, 1)  #was#
    479478            quantities[name] = num.take(quantities[name], gauge_id, axis=1)
    480479           
  • branches/numpy/anuga/coordinate_transforms/geo_reference.py

    r6428 r6441  
    88
    99import types, sys
     10import copy
     11
    1012from anuga.utilities.numerical_tools import ensure_numeric
    1113from anuga.utilities.anuga_exceptions import ANUGAError, TitleError, \
     
    240242    # @return The changed points.
    241243    # @note If 'points' is a list then a changed list is returned.
    242     # @note The input points data is changed.
    243244    def change_points_geo_ref(self, points, points_geo_ref=None):
    244245        """Change the geo reference of a list or numeric array of points to
     
    250251        is_list = isinstance(points, list)
    251252
    252         points = ensure_numeric(points, num.float)
     253        points = ensure_numeric(copy.copy(points), num.float)
    253254
    254255        # sanity checks
     
    308309        is_list = isinstance(points, list)
    309310
    310         # convert to numeric array
    311         points = ensure_numeric(points, num.float)
     311        # convert to numeric array, force a copy
     312        points = ensure_numeric(copy.copy(points), num.float)
    312313
    313314        # sanity checks
     
    328329            points[:,0] += self.xllcorner
    329330            points[:,1] += self.yllcorner
    330             #self.is_absolute = True
    331331
    332332        # if we got a list, return a list
  • branches/numpy/anuga/coordinate_transforms/test_geo_reference.py

    r6428 r6441  
    239239        new_points = g.get_absolute(points)
    240240
    241         self.failUnless(type(new_points) == types.ListType, 'failed')
     241        self.failUnless(isinstance(new_points, list), 'failed')
    242242        self.failUnless(type(new_points) == type(points), 'failed')
    243243        for point, new_point in map(None, points, new_points):
     
    250250        new_points = g.get_absolute(points)
    251251
    252         self.failUnless(type(new_points) == types.ListType, 'failed')
     252        self.failUnless(isinstance(new_points, list), 'failed')
    253253        self.failUnless(type(new_points) == type(points), 'failed')
    254254        for point, new_point in map(None, points, new_points):
     
    259259        # first call
    260260        dx = 10.0
    261         dy = 10.0
     261        dy = 12.0
    262262        g = Geo_reference(56, dx, dy)
    263263        points = [[3.0,34.0], [64.0,6.0]]
     
    265265        new_points = g.get_absolute(points)
    266266
    267         self.failUnless(type(new_points) == types.ListType, 'failed')
    268         self.failUnless(type(new_points) == type(points), 'failed')
    269         for point, new_point in map(None, expected_new_points, new_points):
    270             self.failUnless(point[0] == new_point[0], 'failed')
    271             self.failUnless(point[1] == new_point[1], 'failed')
     267        self.failUnless(isinstance(new_points, list), 'failed')
     268        self.failUnless(type(new_points) == type(points), 'failed')
     269        self.failUnless(new_points == expected_new_points, 'failed')
    272270
    273271        # and repeat from 'new_points = g.get_absolute(points)' above
     
    275273        new_points = g.get_absolute(points)
    276274
    277         self.failUnless(type(new_points) == types.ListType, 'failed')
    278         self.failUnless(type(new_points) == type(points), 'failed')
    279         for point, new_point in map(None, expected_new_points, new_points):
    280             self.failUnless(point[0] == new_point[0], 'failed')
    281             self.failUnless(point[1] == new_point[1], 'failed')
     275        self.failUnless(isinstance(new_points, list), 'failed')
     276        self.failUnless(type(new_points) == type(points), 'failed')
     277        self.failUnless(new_points == expected_new_points, 'failed')
    282278
    283279    def test_get_absolute_array(self):
     
    294290        self.failUnless(isinstance(new_points, num.ndarray), 'failed')
    295291        self.failUnless(type(new_points) == type(points), 'failed')
    296         self.failUnless(num.alltrue(points == new_points), 'failed')
     292        msg = 'points=\n%s\nnew_points=\n%s' % (str(points), str(new_points))
     293        for point, new_point in map(None, points, new_points):
     294            self.failUnless(point[0]+x == new_point[0], 'failed')
     295            self.failUnless(point[1]+y == new_point[1], 'failed')
    297296
    298297        # test with no supplied offsets
     
    307306        # test that calling get_absolute twice does the right thing
    308307        # first call
    309         dx = 10.0
    310         dy = 10.0
     308        dx = 11.0
     309        dy = 13.0
    311310        g = Geo_reference(56, dx, dy)
    312311        points = num.array([[3.0,34.0], [64.0,6.0]])
     
    336335        self.failUnless(isinstance(new_points, num.ndarray), 'failed')
    337336        self.failUnless(type(new_points) == type(points), 'failed')
    338         msg = ('Second call of .get_absolute() returned %s\nexpected %s'
     337        msg = ('Third call of .get_absolute() returned %s\nexpected %s'
    339338               % (str(new_points), str(expected_new_points)))
    340339        self.failUnless(num.alltrue(expected_new_points == new_points), msg)
     
    534533if __name__ == "__main__":
    535534    suite = unittest.makeSuite(geo_referenceTestCase, 'test')
    536     #suite = unittest.makeSuite(geo_referenceTestCase, 'test_functionality_get_absolute')
    537535    runner = unittest.TextTestRunner() #verbosity=2)
    538536    runner.run(suite)
  • branches/numpy/anuga/fit_interpolate/test_fit.py

    r6304 r6441  
    11021102    runner.run(suite)
    11031103
    1104 
    1105 
    1106 
    1107 
  • branches/numpy/anuga/fit_interpolate/test_interpolate.py

    r6360 r6441  
    939939        f = num.array([linear_function(vertices), 2*linear_function(vertices)])
    940940        f = num.transpose(f)
    941         print 'f=\n%s' % str(f)
    942941        z = interp.interpolate_block(f, point_coords)
    943942        answer = [linear_function(point_coords.get_data_points(absolute=True)),
    944943                  2*linear_function(point_coords.get_data_points(absolute=True))
    945944                 ]
    946         print 'After creation, answer=\n%s' % str(answer)
    947945        answer = num.transpose(answer)
    948         print "z=\n%s" % str(z)
    949         print "answer=\n%s" % str(answer)
    950946        msg = ('Expected z\n%s\nto be close to answer\n%s'
    951947               % (str(z), str(answer)))
     
    18511847if __name__ == "__main__":
    18521848    suite = unittest.makeSuite(Test_Interpolate,'test')
    1853     #suite = unittest.makeSuite(Test_Interpolate,'test_interpolate_geo_spatial')
    18541849    runner = unittest.TextTestRunner() #verbosity=1)
    18551850    runner.run(suite)
  • branches/numpy/anuga/geospatial_data/geospatial_data.py

    r6428 r6441  
    918918# @param data_points ??
    919919# @param points_are_lats_longs ??
     920# @note IS THIS USED???
    920921def _set_using_lat_long(latitudes,
    921922                        longitudes,
     
    968969    """Read .pts NetCDF file
    969970
    970     Return a dic of array of points, and dic of array of attribute
     971    Return a (dict_points, dict_attribute, geo_ref)
    971972    eg
    972     dic['points'] = [[1.0,2.0],[3.0,5.0]]
    973     dic['attributelist']['elevation'] = [[7.0,5.0]]
     973    dict['points'] = [[1.0,2.0],[3.0,5.0]]
     974    dict['attributelist']['elevation'] = [[7.0,5.0]]
    974975    """
    975976
     
    11821183
    11831184##
    1184 # @brief Read the body of a .csf file, with blocking.
     1185# @brief Read the body of a .pts file, with blocking.
    11851186# @param fid Handle to already open file.
    11861187# @param start_row Start row index of points to return.
     
    11891190# @return Tuple of (pointlist, attributes).
    11901191def _read_pts_file_blocking(fid, start_row, fin_row, keys):
    1191     '''Read the body of a .csv file.'''
     1192    '''Read the body of a .pts file.'''
    11921193
    11931194    pointlist = num.array(fid.variables['points'][start_row:fin_row])
     
    15141515
    15151516    data_file: must not contain points outside the boundaries defined
    1516                and it either a pts, txt or csv file.
     1517               and it must be either a pts, txt or csv file.
    15171518
    15181519    alpha_list: the alpha values to test in a single list
  • branches/numpy/anuga/geospatial_data/test_geospatial_data.py

    r6428 r6441  
    14121412        new_geospatial = ensure_geospatial(data_points, geo_reference=geo)
    14131413        new_points = new_geospatial.get_data_points(absolute=True)
    1414         assert num.allclose(new_points, ab_points)
     1414        msg = ('new_points=\n%s\nab_points=\n%s'
     1415               % (str(new_points), str(ab_points)))
     1416        assert num.allclose(new_points, ab_points), msg
    14151417
    14161418        geo_reference = Geo_reference(56, 100, 200)
  • branches/numpy/anuga/shallow_water/shallow_water_domain.py

    r6410 r6441  
    16131613
    16141614        # Is this really what we want?
    1615         msg = 'Function %s must return vector' % str(f)
     1615        # info is "(func name, filename, defining line)"
     1616        func_info = (f.func_name, f.func_code.co_filename,
     1617                     f.func_code.co_firstlineno)
     1618        msg = ('Function %s() must return vector (defined in %s, line %d)'
     1619               % func_info)
    16161620        assert hasattr(q, 'len'), msg
    16171621
    1618         msg = ('Return vector from function %s must have same '
    1619                'length as input vectors' % f)
     1622        msg = ('Return vector from function %s() must have same '
     1623               'length as input vectors\nq=%s' % (f.func_name, str(q)))
    16201624        assert len(q) == N, msg
    16211625    else:
     
    16231627            f = float(f)
    16241628        except:
    1625             msg = ('Force field %s must be either a vector function or a '
    1626                    'scalar value (coercible to float).' % str(f))
     1629            msg = ('Force field %s must be a scalar value coercible to float.'
     1630                   % str(f))
    16271631            raise Exception, msg
    16281632
     
    19261930        if self.polygon is not None:
    19271931            # Inlet is polygon
    1928             inlet_region = 'polygon=%s, area=%f m^2' % (self.polygon,
    1929                                                         self.exchange_area)
     1932            inlet_region = ('polygon=\n%s, area=%f m^2' %
     1933                            (self.polygon, self.exchange_area))
    19301934
    19311935            self.exchange_indices = inside_polygon(points, self.polygon)
  • branches/numpy/anuga/shallow_water/test_eq.py

    r6410 r6441  
    6363if __name__ == "__main__":
    6464    suite = unittest.makeSuite(Test_eq,'test_Okada_func')
    65     #suite = unittest.makeSuite(Test_eq,'test_earthquake_tsunami')
    6665    runner = unittest.TextTestRunner()
    6766    runner.run(suite)
  • branches/numpy/anuga/shallow_water/test_shallow_water_domain.py

    r6410 r6441  
    60626062        #The diagonal points of domain 1 are 0, 5, 10, 15
    60636063
    6064         #print points[0], points[5], points[10], points[15]
    6065         msg = ('value was\n%s\nshould be\n'
    6066                '[[0,0], [1.0/3, 1.0/3],\n'
    6067                '[2.0/3, 2.0/3], [1,1]]'
    6068                % str(num.take(points, [0,5,10,15], axis=0)))
    60696064        assert num.allclose(num.take(points, [0,5,10,15], axis=0),
    6070                             [[0,0], [1.0/3, 1.0/3], [2.0/3, 2.0/3], [1,1]]), msg
     6065                            [[0,0], [1.0/3, 1.0/3], [2.0/3, 2.0/3], [1,1]])
    60716066
    60726067
     
    66436638       
    66446639if __name__ == "__main__":
    6645     #suite = unittest.makeSuite(Test_Shallow_Water, 'test')
    6646     suite = unittest.makeSuite(Test_Shallow_Water, 'test_get_maximum_inundation_from_sww')
     6640    suite = unittest.makeSuite(Test_Shallow_Water, 'test')
    66476641    runner = unittest.TextTestRunner(verbosity=1)   
    66486642    runner.run(suite)
  • branches/numpy/anuga/utilities/numerical_tools.py

    r6428 r6441  
    250250                     If not, let numeric package decide.
    251251                     numpy assumes float64 if no type in A.
     252                     typecode will always be one of num.float, num.int, etc.
     253
     254    Note that num.array(A, dtype) will sometimes copy.  Use 'copy=False' to
     255    copy only when required.
    252256
    253257    This function is necessary as array(A) can cause memory overflow.
     
    264268            return num.array(A)
    265269    else:
    266         if isinstance(A, num.ndarray):
    267             if A.dtype == typecode:
    268 #                return num.array(A)  #FIXME: Shouldn't this just return A?
    269                 return A
    270             else:
    271                 return num.array(A, dtype=typecode)
    272         else:
    273             return num.array(A, dtype=typecode)
     270        return num.array(A, dtype=typecode, copy=False)
    274271
    275272
  • branches/numpy/anuga/utilities/quad.py

    r6158 r6441  
    184184                    #y = self.mesh.coordinates[point][1]
    185185                    node = self.mesh.get_node(point, absolute=True)
    186                     print "node", node
    187                     print "(" + str(node[0]) + "," + str(node[1]) + ")"
    188                     raise 'point not in region: %s' %str(point)
     186                    msg = ('point not in region: %s\nnode=%s'
     187                           % (str(point), str(node)))
     188                    raise Exception, msg
    189189               
    190190               
  • branches/numpy/anuga/utilities/test_numerical_tools.py

    r6410 r6441  
    466466#        t(num.array('abc', num.float), False)
    467467
     468    ##
     469    # @brief Test to see if ensure_numeric() behaves as we expect.
     470    # @note Under Numeric ensure_numeric() *always* returned a copy.
     471    #       Under numpy it copies only when it has to.
     472    def test_ensure_numeric_copy(self):
     473        #####
     474        # Make 'points' a _list_ of coordinates.
     475        # Should be changed by ensure_numeric().
     476        #####
     477        points = [[1.,2.], [3.,4.], [5.,6.]]
     478        points_id = id(points)
     479
     480        points_new = ensure_numeric(points, num.float)
     481        points_new_id = id(points_new)
     482
     483        msg = 'ensure_numeric() should return a copy of a list'
     484        self.failUnless(points_new_id != points_id, msg)
     485
     486        # should never change it's input parameter
     487        msg = "ensure_numeric() changed it's input parameter"
     488        self.failUnless(points_id == id(points), msg)
     489
     490        #####
     491        # Make 'points' a _tuple_ of coordinates.
     492        # Should be changed by ensure_numeric().
     493        #####
     494        points = ((1.,2.), (3.,4.), (5.,6.))
     495        points_id = id(points)
     496
     497        points_new = ensure_numeric(points, num.int)
     498        points_new_id = id(points_new)
     499
     500        msg = 'ensure_numeric() should return a copy of a list'
     501        self.failUnless(points_new_id != points_id, msg)
     502
     503        # should never change it's input parameter
     504        msg = "ensure_numeric() changed it's input parameter"
     505        self.failUnless(points_id == id(points), msg)
     506
     507        #####
     508        # Make 'points' a numeric array of float coordinates.
     509        # Should NOT be changed by ensure_numeric().
     510        #####
     511        points = num.array([[1.,2.], [3.,4.], [5.,6.]], num.float)
     512        points_id = id(points)
     513
     514        points_new = ensure_numeric(points, num.float)
     515        points_new_id = id(points_new)
     516
     517        msg = 'ensure_numeric() should return the original input'
     518        self.failUnless(points_new_id == points_id, msg)
     519
     520        # should never change it's input parameter
     521        msg = "ensure_numeric() changed it's input parameter"
     522        self.failUnless(points_id == id(points), msg)
     523
     524        #####
     525        # Make 'points' a numeric array of int coordinates.
     526        # Should be changed by ensure_numeric().
     527        #####
     528        points = num.array([[1,2], [3,4], [5,6]], num.int)
     529        points_id = id(points)
     530
     531        points_new = ensure_numeric(points, num.float)
     532        points_new_id = id(points_new)
     533
     534        msg = 'ensure_numeric() should return a copy of the input'
     535        self.failUnless(points_new_id != points_id, msg)
     536
     537        # should never change it's input parameter
     538        msg = "ensure_numeric() changed it's input parameter"
     539        self.failUnless(points_id == id(points), msg)
     540
     541        #####
     542        # Make 'points' a numeric array of int coordinates.
     543        # Should NOT be changed by ensure_numeric(, num.int).
     544        #####
     545        points = num.array([[1,2], [3,4], [5,6]], num.int)
     546        points_id = id(points)
     547
     548        points_new = ensure_numeric(points, num.int)
     549        points_new_id = id(points_new)
     550
     551        msg = 'ensure_numeric() should return the original input'
     552        self.failUnless(points_new_id == points_id, msg)
     553
     554        # should never change it's input parameter
     555        msg = "ensure_numeric() changed it's input parameter"
     556        self.failUnless(points_id == id(points), msg)
     557
    468558################################################################################
    469559
  • branches/numpy/anuga/utilities/test_polygon.py

    r6410 r6441  
    15511551
    15521552    def test_inside_polygon_geospatial(self):
    1553         # Simplest case: Polygon is the unit square
     1553        #Simplest case: Polygon is the unit square
    15541554        polygon_absolute = [[0,0], [1,0], [1,1], [0,1]]
    15551555        poly_geo_ref = Geo_reference(57, 100, 100)
    15561556        polygon = poly_geo_ref.change_points_geo_ref(polygon_absolute)
    15571557        poly_spatial = Geospatial_data(polygon, geo_reference=poly_geo_ref)
    1558         point_absolute = (0.5, 0.5)
     1558
     1559        points_absolute = (0.5, 0.5)
    15591560        points_geo_ref = Geo_reference(57, 78, -56)
    1560         point = points_geo_ref.change_points_geo_ref(point_absolute)
    1561         point_spatial = Geospatial_data(point, geo_reference=points_geo_ref)
    1562 
    1563         msg = ('point_absolute\n%s\nis not inside polygon_absolute\n%s'
    1564                % (str(point_absolute), str(polygon_absolute)))
    1565         assert is_inside_polygon(point_absolute, polygon_absolute), msg
    1566 
    1567         msg = ('ensure_numeric(point_absolute)\n%s\n'
    1568                'is not inside ensure_numeric(polygon_absolute)\n%s'
    1569                % (str(ensure_numeric(ensure_numeric(point_absolute))),
    1570                   str(polygon_absolute)))
    1571         assert is_inside_polygon(ensure_numeric(point_absolute),
    1572                                  ensure_numeric(polygon_absolute)), msg
    1573 
    1574         msg = ('point_absolute\n%s\nis not inside poly_spatial\n%s'
    1575                % (str(point_absolute), str(poly_spatial)))
    1576         assert is_inside_polygon(point_absolute, poly_spatial), msg
    1577 
    1578         msg = ('point_spatial\n%s\nis not inside poly_spatial\n%s'
    1579                % (str(point_spatial), str(poly_spatial)))
    1580         assert is_inside_polygon(point_spatial, poly_spatial), msg
    1581 
    1582         msg = ('point_spatial\n%s\nis not inside polygon_absolute\n%s'
    1583                % (str(point_spatial), str(polygon_absolute)))
    1584         assert is_inside_polygon(point_spatial, polygon_absolute), msg
    1585 
    1586         msg = ('point_absolute\n%s\nis not inside polygon_absolute\n%s'
    1587                % (str(point_absolute), str(polygon_absolute)))
    1588         assert is_inside_polygon(point_absolute, polygon_absolute), msg
     1561        points = points_geo_ref.change_points_geo_ref(points_absolute)
     1562        points_spatial = Geospatial_data(points, geo_reference=points_geo_ref)
     1563
     1564        assert is_inside_polygon(points_absolute, polygon_absolute)
     1565        assert is_inside_polygon(ensure_numeric(points_absolute),
     1566                                 ensure_numeric(polygon_absolute))
     1567        assert is_inside_polygon(points_absolute, poly_spatial)
     1568        assert is_inside_polygon(points_spatial, poly_spatial)
     1569        assert is_inside_polygon(points_spatial, polygon_absolute)
     1570
     1571        assert is_inside_polygon(points_absolute, polygon_absolute)
    15891572
    15901573    def NOtest_decimate_polygon(self):
     
    17581741if __name__ == "__main__":
    17591742    suite = unittest.makeSuite(Test_Polygon,'test')
    1760     #suite = unittest.makeSuite(Test_Polygon,'test_inside_polygon_badtest_1')
    17611743    runner = unittest.TextTestRunner()
    17621744    runner.run(suite)
Note: See TracChangeset for help on using the changeset viewer.