mirror of
https://github.com/wassname/geopandas.git
synced 2026-09-11 12:10:59 +08:00
MAINT: switch old deprecationwarnings to futurewarnings (#2447)
This commit is contained in:
@@ -1864,7 +1864,7 @@ individually so that features may have different properties
|
||||
warnings.warn(
|
||||
"'^' operator will be deprecated. Use the 'symmetric_difference' "
|
||||
"method instead.",
|
||||
DeprecationWarning,
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.geometry.symmetric_difference(other)
|
||||
@@ -1873,7 +1873,7 @@ individually so that features may have different properties
|
||||
"""Implement | operator as for builtin set type"""
|
||||
warnings.warn(
|
||||
"'|' operator will be deprecated. Use the 'union' method instead.",
|
||||
DeprecationWarning,
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.geometry.union(other)
|
||||
@@ -1882,7 +1882,7 @@ individually so that features may have different properties
|
||||
"""Implement & operator as for builtin set type"""
|
||||
warnings.warn(
|
||||
"'&' operator will be deprecated. Use the 'intersection' method instead.",
|
||||
DeprecationWarning,
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.geometry.intersection(other)
|
||||
@@ -1891,7 +1891,7 @@ individually so that features may have different properties
|
||||
"""Implement - operator as for builtin set type"""
|
||||
warnings.warn(
|
||||
"'-' operator will be deprecated. Use the 'difference' method instead.",
|
||||
DeprecationWarning,
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.geometry.difference(other)
|
||||
|
||||
@@ -1245,7 +1245,7 @@ e": "Feature", "properties": {}, "geometry": {"type": "Point", "coordinates": [3
|
||||
warnings.warn(
|
||||
"'^' operator will be deprecated. Use the 'symmetric_difference' "
|
||||
"method instead.",
|
||||
DeprecationWarning,
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.symmetric_difference(other)
|
||||
@@ -1254,7 +1254,7 @@ e": "Feature", "properties": {}, "geometry": {"type": "Point", "coordinates": [3
|
||||
"""Implement | operator as for builtin set type"""
|
||||
warnings.warn(
|
||||
"'|' operator will be deprecated. Use the 'union' method instead.",
|
||||
DeprecationWarning,
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.union(other)
|
||||
@@ -1263,7 +1263,7 @@ e": "Feature", "properties": {}, "geometry": {"type": "Point", "coordinates": [3
|
||||
"""Implement & operator as for builtin set type"""
|
||||
warnings.warn(
|
||||
"'&' operator will be deprecated. Use the 'intersection' method instead.",
|
||||
DeprecationWarning,
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.intersection(other)
|
||||
@@ -1272,7 +1272,7 @@ e": "Feature", "properties": {}, "geometry": {"type": "Point", "coordinates": [3
|
||||
"""Implement - operator as for builtin set type"""
|
||||
warnings.warn(
|
||||
"'-' operator will be deprecated. Use the 'difference' method instead.",
|
||||
DeprecationWarning,
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
return self.difference(other)
|
||||
|
||||
@@ -269,7 +269,7 @@ def read_file(*args, **kwargs):
|
||||
warnings.warn(
|
||||
"geopandas.io.file.read_file() is intended for internal "
|
||||
"use only, and will be deprecated. Use geopandas.read_file() instead.",
|
||||
DeprecationWarning,
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
|
||||
@@ -281,7 +281,7 @@ def to_file(*args, **kwargs):
|
||||
"geopandas.io.file.to_file() is intended for internal "
|
||||
"use only, and will be deprecated. Use GeoDataFrame.to_file() "
|
||||
"or GeoSeries.to_file() instead.",
|
||||
DeprecationWarning,
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
|
||||
|
||||
+1
-1
@@ -182,7 +182,7 @@ def read_postgis(*args, **kwargs):
|
||||
warnings.warn(
|
||||
"geopandas.io.sql.read_postgis() is intended for internal "
|
||||
"use only, and will be deprecated. Use geopandas.read_postgis() instead.",
|
||||
DeprecationWarning,
|
||||
FutureWarning,
|
||||
stacklevel=2,
|
||||
)
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@ def test_to_file_empty(tmpdir):
|
||||
|
||||
def test_to_file_privacy(tmpdir, df_nybb):
|
||||
tempfilename = os.path.join(str(tmpdir), "test.shp")
|
||||
with pytest.warns(DeprecationWarning):
|
||||
with pytest.warns(FutureWarning):
|
||||
geopandas.io.file.to_file(df_nybb, tempfilename)
|
||||
|
||||
|
||||
@@ -679,7 +679,7 @@ def test_read_file_empty_shapefile(tmpdir):
|
||||
|
||||
|
||||
def test_read_file_privacy(tmpdir, df_nybb):
|
||||
with pytest.warns(DeprecationWarning):
|
||||
with pytest.warns(FutureWarning):
|
||||
geopandas.io.file.read_file(geopandas.datasets.get_path("nybb"))
|
||||
|
||||
|
||||
|
||||
@@ -326,7 +326,7 @@ class TestIO:
|
||||
create_postgis(con, df_nybb)
|
||||
|
||||
sql = "SELECT * FROM nybb;"
|
||||
with pytest.warns(DeprecationWarning):
|
||||
with pytest.warns(FutureWarning):
|
||||
geopandas.io.sql.read_postgis(sql, con)
|
||||
|
||||
def test_write_postgis_default(self, engine_postgis, df_nybb):
|
||||
|
||||
@@ -11,14 +11,14 @@ from packaging.version import Version
|
||||
from ._decorator import doc
|
||||
|
||||
|
||||
def deprecated(new):
|
||||
def deprecated(new, warning_type=FutureWarning):
|
||||
"""Helper to provide deprecation warning."""
|
||||
|
||||
def old(*args, **kwargs):
|
||||
warnings.warn(
|
||||
"{} is intended for internal ".format(new.__name__[1:])
|
||||
+ "use only, and will be deprecated.",
|
||||
DeprecationWarning,
|
||||
warning_type,
|
||||
stacklevel=2,
|
||||
)
|
||||
new(*args, **kwargs)
|
||||
|
||||
@@ -1224,39 +1224,39 @@ class TestGeomMethods:
|
||||
# Test '&', '|', '^', and '-'
|
||||
#
|
||||
def test_intersection_operator(self):
|
||||
with pytest.warns(DeprecationWarning):
|
||||
with pytest.warns(FutureWarning):
|
||||
self._test_binary_operator("__and__", self.t1, self.g1, self.g2)
|
||||
with pytest.warns(DeprecationWarning):
|
||||
with pytest.warns(FutureWarning):
|
||||
self._test_binary_operator("__and__", self.t1, self.gdf1, self.g2)
|
||||
|
||||
def test_union_operator(self):
|
||||
with pytest.warns(DeprecationWarning):
|
||||
with pytest.warns(FutureWarning):
|
||||
self._test_binary_operator("__or__", self.sq, self.g1, self.g2)
|
||||
with pytest.warns(DeprecationWarning):
|
||||
with pytest.warns(FutureWarning):
|
||||
self._test_binary_operator("__or__", self.sq, self.gdf1, self.g2)
|
||||
|
||||
def test_union_operator_polygon(self):
|
||||
with pytest.warns(DeprecationWarning):
|
||||
with pytest.warns(FutureWarning):
|
||||
self._test_binary_operator("__or__", self.sq, self.g1, self.t2)
|
||||
with pytest.warns(DeprecationWarning):
|
||||
with pytest.warns(FutureWarning):
|
||||
self._test_binary_operator("__or__", self.sq, self.gdf1, self.t2)
|
||||
|
||||
def test_symmetric_difference_operator(self):
|
||||
with pytest.warns(DeprecationWarning):
|
||||
with pytest.warns(FutureWarning):
|
||||
self._test_binary_operator("__xor__", self.sq, self.g3, self.g4)
|
||||
with pytest.warns(DeprecationWarning):
|
||||
with pytest.warns(FutureWarning):
|
||||
self._test_binary_operator("__xor__", self.sq, self.gdf3, self.g4)
|
||||
|
||||
def test_difference_series2(self):
|
||||
expected = GeoSeries([GeometryCollection(), self.t2])
|
||||
with pytest.warns(DeprecationWarning):
|
||||
with pytest.warns(FutureWarning):
|
||||
self._test_binary_operator("__sub__", expected, self.g1, self.g2)
|
||||
with pytest.warns(DeprecationWarning):
|
||||
with pytest.warns(FutureWarning):
|
||||
self._test_binary_operator("__sub__", expected, self.gdf1, self.g2)
|
||||
|
||||
def test_difference_poly2(self):
|
||||
expected = GeoSeries([self.t1, self.t1])
|
||||
with pytest.warns(DeprecationWarning):
|
||||
with pytest.warns(FutureWarning):
|
||||
self._test_binary_operator("__sub__", expected, self.g1, self.t2)
|
||||
with pytest.warns(DeprecationWarning):
|
||||
with pytest.warns(FutureWarning):
|
||||
self._test_binary_operator("__sub__", expected, self.gdf1, self.t2)
|
||||
|
||||
@@ -1438,8 +1438,8 @@ class TestPlotCollections:
|
||||
with pytest.raises((TypeError, ValueError)):
|
||||
_plot_point_collection(ax, self.points, color="not color")
|
||||
|
||||
# check DeprecationWarning
|
||||
with pytest.warns(DeprecationWarning):
|
||||
# check FutureWarning
|
||||
with pytest.warns(FutureWarning):
|
||||
plot_point_collection(ax, self.points)
|
||||
|
||||
def test_points_values(self):
|
||||
@@ -1511,8 +1511,8 @@ class TestPlotCollections:
|
||||
# not a color
|
||||
with pytest.raises((TypeError, ValueError)):
|
||||
_plot_linestring_collection(ax, self.lines, color="not color")
|
||||
# check DeprecationWarning
|
||||
with pytest.warns(DeprecationWarning):
|
||||
# check FutureWarning
|
||||
with pytest.warns(FutureWarning):
|
||||
plot_linestring_collection(ax, self.lines)
|
||||
|
||||
def test_linestrings_values(self):
|
||||
@@ -1603,8 +1603,8 @@ class TestPlotCollections:
|
||||
# not a color
|
||||
with pytest.raises((TypeError, ValueError)):
|
||||
_plot_polygon_collection(ax, self.polygons, color="not color")
|
||||
# check DeprecationWarning
|
||||
with pytest.warns(DeprecationWarning):
|
||||
# check FutureWarning
|
||||
with pytest.warns(FutureWarning):
|
||||
plot_polygon_collection(ax, self.polygons)
|
||||
|
||||
def test_polygons_values(self):
|
||||
|
||||
Reference in New Issue
Block a user