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

After changes to get_absolute, ensure_numeric, etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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)
Note: See TracChangeset for help on using the changeset viewer.