Ticket #19366: 19366-4.diff
File 19366-4.diff, 4.4 KB (added by , 12 years ago) |
---|
-
django/contrib/gis/geos/mutable_list.py
diff --git a/django/contrib/gis/geos/mutable_list.py b/django/contrib/gis/geos/mutable_list.py index 820cdfa..0418282 100644
a b class ListMixin(object): 149 149 return self 150 150 151 151 def __eq__(self, other): 152 for i in range(len(self)): 152 olen = len(other) 153 for i in range(olen): 153 154 try: 154 155 c = self[i] == other[i] 155 except IndexError:156 # must be other isshorter156 except self._IndexError: 157 # self must be shorter 157 158 return False 158 159 if not c: 159 160 return False 160 return True161 return len(self) == olen 161 162 162 163 def __lt__(self, other): 163 slen = len(self)164 for i in range( slen):164 olen = len(other) 165 for i in range(olen): 165 166 try: 166 167 c = self[i] < other[i] 167 except IndexError:168 # must be other isshorter169 return False168 except self._IndexError: 169 # self must be shorter 170 return True 170 171 if c: 171 172 return c 172 return slen < len(other) 173 elif other[i] < self[i]: 174 return False 175 return len(self) < olen 173 176 174 177 ### Public list interface Methods ### 175 178 ## Non-mutating ## -
django/contrib/gis/geos/tests/test_geos.py
diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py index 283daa4..ec320f9 100644
a b class GEOSTest(unittest.TestCase, TestDataMixin): 451 451 self.assertEqual(poly.wkt, Polygon(*tuple(r for r in poly)).wkt) 452 452 self.assertEqual(poly.wkt, Polygon(*tuple(LinearRing(r.tuple) for r in poly)).wkt) 453 453 454 def test_polygon_comparison(self): 455 p1 = Polygon(((0, 0), (0, 1), (1, 1), (1, 0), (0, 0))) 456 p2 = Polygon(((0, 0), (0, 1), (1, 0), (0, 0))) 457 self.assertTrue(p1 > p2) 458 self.assertFalse(p1 < p2) 459 self.assertFalse(p2 > p1) 460 self.assertTrue(p2 < p1) 461 462 p3 = Polygon(((0, 0), (0, 1), (1, 1), (2, 0), (0, 0))) 463 p4 = Polygon(((0, 0), (0, 1), (2, 2), (1, 0), (0, 0))) 464 self.assertFalse(p4 < p3) 465 self.assertTrue(p3 < p4) 466 self.assertTrue(p4 > p3) 467 self.assertFalse(p3 > p4) 468 454 469 def test_multipolygons(self): 455 470 "Testing MultiPolygon objects." 456 471 prev = fromstr('POINT (0 0)') -
django/contrib/gis/geos/tests/test_mutable_list.py
diff --git a/django/contrib/gis/geos/tests/test_mutable_list.py b/django/contrib/gis/geos/tests/test_mutable_list.py index 675505f..988d841 100644
a b class ListMixinTest(unittest.TestCase): 363 363 364 364 pl, ul = self.lists_of_len() 365 365 self.assertEqual(pl, ul, 'cmp for equal') 366 self.assertFalse(ul == pl + [2], 'cmp for not equal') 366 367 self.assertTrue(pl >= ul, 'cmp for gte self') 367 368 self.assertTrue(pl <= ul, 'cmp for lte self') 368 369 self.assertTrue(ul >= pl, 'cmp for self gte') … … class ListMixinTest(unittest.TestCase): 377 378 self.assertTrue(ul < pl + [2], 'cmp') 378 379 self.assertTrue(ul <= pl + [2], 'cmp') 379 380 381 # Also works with a custom IndexError 382 ul_longer = ul + [2] 383 ul_longer._IndexError = TypeError 384 ul._IndexError = TypeError 385 self.assertFalse(ul_longer == pl) 386 self.assertFalse(ul == ul_longer) 387 self.assertTrue(ul_longer > ul) 388 380 389 pl[1] = 20 381 390 self.assertTrue(pl > ul, 'cmp for gt self') 382 391 self.assertTrue(ul < pl, 'cmp for self lt') -
docs/ref/contrib/gis/geos.txt
diff --git a/docs/ref/contrib/gis/geos.txt b/docs/ref/contrib/gis/geos.txt index eb20b1f..7d7c327 100644
a b is returned instead. 656 656 657 657 Returns the number of interior rings in this geometry. 658 658 659 .. admonition:: Comparing Polygons 660 661 Note that it is possible to compare ``Polygon`` objects directly with ``<`` 662 or ``>``, but as the comparison is made through Polygon's 663 :class:`LineString`, it does not mean much (but is consistent and quick). 664 You can always force the comparison with the :attr:`~GEOSGeometry.area` 665 property:: 666 667 >>> if poly_1.area > poly_2.area: 668 >>> pass 669 659 670 Geometry Collections 660 671 ==================== 661 672