Loading django/contrib/gis/geos/point.py +18 −3 Original line number Diff line number Diff line Loading @@ -172,14 +172,29 @@ class Point(GEOSGeometry): self.z = value # ### Tuple setting and retrieval routines. ### def get_coords(self): @property def tuple(self): "Returns a tuple of the point." return self._cs.tuple def set_coords(self, tup): @tuple.setter def tuple(self, tup): "Sets the coordinates of the point with the given tuple." self._cs[0] = tup def get_coords(self): warnings.warn( "`get_coords()` is deprecated, use the `tuple` property instead.", RemovedInDjango20Warning, 2 ) return self.tuple def set_coords(self, tup): warnings.warn( "`set_coords()` is deprecated, use the `tuple` property instead.", RemovedInDjango20Warning, 2 ) self.tuple = tup # The tuple and coords properties tuple = property(get_coords, set_coords) coords = tuple docs/internals/deprecation.txt +3 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,9 @@ details on these changes. * The ``get_x()``, ``set_x()``, ``get_y()``, ``set_y()``, ``get_z()``, and ``set_z()`` methods of ``django.contrib.gis.geos.Point`` will be removed. * The ``get_coords()`` and ``set_coords()`` methods of ``django.contrib.gis.geos.Point`` will be removed. .. _deprecation-removed-in-1.10: 1.10 Loading docs/releases/1.10.txt +4 −0 Original line number Diff line number Diff line Loading @@ -339,6 +339,10 @@ This prevents confusion about an assignment resulting in an implicit save. ``set_z()`` methods of :class:`~django.contrib.gis.geos.Point` are deprecated in favor of the ``x``, ``y``, and ``z`` properties. * The ``get_coords()`` and ``set_coords()`` methods of :class:`~django.contrib.gis.geos.Point` are deprecated in favor of the ``tuple`` property. Miscellaneous ~~~~~~~~~~~~~ Loading tests/gis_tests/geos_tests/test_geos.py +13 −4 Original line number Diff line number Diff line Loading @@ -787,7 +787,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin): # Testing a 3D Point pnt = Point(2, 3, 8) self.assertEqual((2., 3., 8.), pnt.coords) self.assertRaises(TypeError, pnt.set_coords, (1., 2.)) with self.assertRaises(TypeError): pnt.tuple = (1., 2.) pnt.coords = (1., 2., 3.) self.assertEqual((1., 2., 3.), pnt.coords) Loading Loading @@ -1156,6 +1157,14 @@ class GEOSTest(unittest.TestCase, TestDataMixin): self.assertEqual((p.get_x(), p.get_y(), p.get_z()), (p.x, p.y, p.z)) p.set_x(3) p.set_y(1) p.set_z(2) self.assertEqual((p.x, p.y, p.z), (3, 1, 2)) p.set_y(2) p.set_z(1) self.assertEqual((p.x, p.y, p.z), (3, 2, 1)) @ignore_warnings(category=RemovedInDjango20Warning) def test_deprecated_point_tuple_getters_setters(self): p = Point(1, 2, 3) self.assertEqual(p.get_coords(), (p.x, p.y, p.z)) p.set_coords((3, 2, 1)) self.assertEqual(p.get_coords(), (3, 2, 1)) Loading
django/contrib/gis/geos/point.py +18 −3 Original line number Diff line number Diff line Loading @@ -172,14 +172,29 @@ class Point(GEOSGeometry): self.z = value # ### Tuple setting and retrieval routines. ### def get_coords(self): @property def tuple(self): "Returns a tuple of the point." return self._cs.tuple def set_coords(self, tup): @tuple.setter def tuple(self, tup): "Sets the coordinates of the point with the given tuple." self._cs[0] = tup def get_coords(self): warnings.warn( "`get_coords()` is deprecated, use the `tuple` property instead.", RemovedInDjango20Warning, 2 ) return self.tuple def set_coords(self, tup): warnings.warn( "`set_coords()` is deprecated, use the `tuple` property instead.", RemovedInDjango20Warning, 2 ) self.tuple = tup # The tuple and coords properties tuple = property(get_coords, set_coords) coords = tuple
docs/internals/deprecation.txt +3 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,9 @@ details on these changes. * The ``get_x()``, ``set_x()``, ``get_y()``, ``set_y()``, ``get_z()``, and ``set_z()`` methods of ``django.contrib.gis.geos.Point`` will be removed. * The ``get_coords()`` and ``set_coords()`` methods of ``django.contrib.gis.geos.Point`` will be removed. .. _deprecation-removed-in-1.10: 1.10 Loading
docs/releases/1.10.txt +4 −0 Original line number Diff line number Diff line Loading @@ -339,6 +339,10 @@ This prevents confusion about an assignment resulting in an implicit save. ``set_z()`` methods of :class:`~django.contrib.gis.geos.Point` are deprecated in favor of the ``x``, ``y``, and ``z`` properties. * The ``get_coords()`` and ``set_coords()`` methods of :class:`~django.contrib.gis.geos.Point` are deprecated in favor of the ``tuple`` property. Miscellaneous ~~~~~~~~~~~~~ Loading
tests/gis_tests/geos_tests/test_geos.py +13 −4 Original line number Diff line number Diff line Loading @@ -787,7 +787,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin): # Testing a 3D Point pnt = Point(2, 3, 8) self.assertEqual((2., 3., 8.), pnt.coords) self.assertRaises(TypeError, pnt.set_coords, (1., 2.)) with self.assertRaises(TypeError): pnt.tuple = (1., 2.) pnt.coords = (1., 2., 3.) self.assertEqual((1., 2., 3.), pnt.coords) Loading Loading @@ -1156,6 +1157,14 @@ class GEOSTest(unittest.TestCase, TestDataMixin): self.assertEqual((p.get_x(), p.get_y(), p.get_z()), (p.x, p.y, p.z)) p.set_x(3) p.set_y(1) p.set_z(2) self.assertEqual((p.x, p.y, p.z), (3, 1, 2)) p.set_y(2) p.set_z(1) self.assertEqual((p.x, p.y, p.z), (3, 2, 1)) @ignore_warnings(category=RemovedInDjango20Warning) def test_deprecated_point_tuple_getters_setters(self): p = Point(1, 2, 3) self.assertEqual(p.get_coords(), (p.x, p.y, p.z)) p.set_coords((3, 2, 1)) self.assertEqual(p.get_coords(), (3, 2, 1))