Skip to content

Commit

Permalink
MNT: Use FutureWarning for pyproj.transform|itransform (#1160)
Browse files Browse the repository at this point in the history
  • Loading branch information
snowman2 committed Oct 11, 2022
1 parent 3009c5c commit 837d965
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions pyproj/transformer.py
Expand Up @@ -1243,7 +1243,7 @@ def transform( # pylint: disable=invalid-name
"See: https://pyproj4.github.io/pyproj/stable/"
"gotchas.html#upgrading-to-pyproj-2-from-pyproj-1"
),
DeprecationWarning,
FutureWarning,
stacklevel=2,
)
return Transformer.from_proj(p1, p2, always_xy=always_xy).transform(
Expand Down Expand Up @@ -1324,7 +1324,7 @@ def itransform( # pylint: disable=invalid-name
"See: https://pyproj4.github.io/pyproj/stable/"
"gotchas.html#upgrading-to-pyproj-2-from-pyproj-1"
),
DeprecationWarning,
FutureWarning,
stacklevel=2,
)
return Transformer.from_proj(p1, p2, always_xy=always_xy).itransform(
Expand Down
2 changes: 1 addition & 1 deletion test/test_datum.py
Expand Up @@ -12,7 +12,7 @@ def test_datum(proj_class):
s_1 = -111.5
s_2 = 45.25919444444
p2 = proj_class(proj="utm", zone=10, datum="NAD27")
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
x2, y2 = transform(p1, p2, s_1, s_2)
if grids_available("us_noaa_emhpgn.tif"):
assert_almost_equal((x2, y2), (1402286.33, 5076292.30), decimal=2)
Expand Down
8 changes: 4 additions & 4 deletions test/test_datum_shift.py
Expand Up @@ -36,29 +36,29 @@


def test_shift_wgs84_to_utm33():
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
xutm33, yutm33, zutm33 = transform(
WGS84_PROJ, UTM_33_PROJ, WGS84_lon, WGS84_lat, WGS84_z
)
assert_almost_equal((xutm33, yutm33, zutm33), (UTM_x, UTM_y, UTM_z))


def test_shift_utm33_to_wgs84():
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
back_lon, back_lat, back_z = transform(
UTM_33_PROJ, WGS84_PROJ, UTM_x, UTM_y, UTM_z
)
assert_almost_equal((back_lon, back_lat, back_z), (WGS84_lon, WGS84_lat, WGS84_z))


def test_shift_wgs84_to_gaussb_no_ellisoidal_height():
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
xgb, ygb, zgb = transform(WGS84_PROJ, GAUSSSB_PROJ, WGS84_lon, WGS84_lat, 0)
assert_almost_equal((xgb, ygb, zgb), (GB_x, 5055619.899, 0), decimal=2)


def test_shift_gaussb_to_wgs84_no_ellisoidal_height():
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
back_lon, back_lat, back_z = transform(GAUSSSB_PROJ, WGS84_PROJ, GB_x, GB_y, 0)
assert_almost_equal(
(back_lon, back_lat, back_z), (WGS84_lon, WGS84_lat, 0), decimal=3
Expand Down
2 changes: 1 addition & 1 deletion test/test_doctest_wrapper.py
Expand Up @@ -44,7 +44,7 @@ def test_doctests__network():
"""
with proj_network_env():
pyproj.network.set_network_enabled(active=True)
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
failure_count, _ = doctest.testmod(pyproj.transformer, verbose=True)

assert failure_count == 0, f"{failure_count} of the doctests failed"
6 changes: 3 additions & 3 deletions test/test_proj.py
Expand Up @@ -130,13 +130,13 @@ def setUp(self):
def test_tranform_none_1st_parmeter(self):
# test should raise Type error if projections are not of Proj classes
# version 1.9.4 produced AttributeError, now should raise TypeError
with pytest.warns(DeprecationWarning), pytest.raises(CRSError):
with pytest.warns(FutureWarning), pytest.raises(CRSError):
transform(None, self.p, -74, 39)

def test_tranform_none_2nd_parmeter(self):
# test should raise Type error if projections are not of Proj classes
# version 1.9.4 has a Segmentation Fault, now should raise TypeError
with pytest.warns(DeprecationWarning), pytest.raises(CRSError):
with pytest.warns(FutureWarning), pytest.raises(CRSError):
transform(self.p, None, -74, 39)


Expand All @@ -155,7 +155,7 @@ def test_latlong_typeerror(self):
p = Proj("+proj=stere +lon_0=-39 +lat_0=90 +lat_ts=71.0 +ellps=WGS84")
self.assertTrue(isinstance(p, Proj))
# if not patched this line raises a "TypeError: p2 must be a Proj class"
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
lon, lat = transform(p, p.to_latlong(), 200000, 400000)


Expand Down
4 changes: 2 additions & 2 deletions test/test_transform.py
Expand Up @@ -36,12 +36,12 @@ def test_transform():
print("max/min x and y for awips218 grid")
print(numpy.minimum.reduce(numpy.ravel(x1)), numpy.maximum.reduce(numpy.ravel(x1)))
print(numpy.minimum.reduce(numpy.ravel(y1)), numpy.maximum.reduce(numpy.ravel(y1)))
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
x2, y2 = transform(awips218, awips221, x1, y1)
print("max/min x and y for awips218 grid in awips221 coordinates")
print(numpy.minimum.reduce(numpy.ravel(x2)), numpy.maximum.reduce(numpy.ravel(x2)))
print(numpy.minimum.reduce(numpy.ravel(y2)), numpy.maximum.reduce(numpy.ravel(y2)))
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
x3, y3 = transform(awips221, awips218, x2, y2)
print("error for reverse transformation back to awips218 coords")
print("(should be close to zero)")
Expand Down
34 changes: 17 additions & 17 deletions test/test_transformer.py
Expand Up @@ -34,7 +34,7 @@ def test_tranform_wgs84_to_custom():
)
wgs84 = pyproj.Proj("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
lat, lon = 51.04715, 3.23406
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
xx, yy = pyproj.transform(wgs84, custom_proj, lon, lat)
assert f"{xx:.3f} {yy:.3f}" == "212.623 4604.975"

Expand All @@ -45,7 +45,7 @@ def test_transform_wgs84_to_alaska():
lat_lon_proj = pyproj.Proj(init="epsg:4326", preserve_units=False)
alaska_aea_proj = pyproj.Proj(init="epsg:2964", preserve_units=False)
test = (-179.72638, 49.752533)
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
xx, yy = pyproj.transform(lat_lon_proj, alaska_aea_proj, *test)
if grids_available("us_noaa_alaska.tif"):
assert f"{xx:.3f} {yy:.3f}" == "-1824924.495 330822.800"
Expand All @@ -59,13 +59,13 @@ def test_illegal_transformation():
with pytest.warns(FutureWarning):
p1 = pyproj.Proj(init="epsg:4326")
p2 = pyproj.Proj(init="epsg:3857")
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
xx, yy = pyproj.transform(
p1, p2, (-180, -180, 180, 180, -180), (-90, 90, 90, -90, -90)
)
assert np.all(np.isinf(xx))
assert np.all(np.isinf(yy))
with pytest.warns(DeprecationWarning), pytest.raises(ProjError):
with pytest.warns(FutureWarning), pytest.raises(ProjError):
pyproj.transform(
p1, p2, (-180, -180, 180, 180, -180), (-90, 90, 90, -90, -90), errcheck=True
)
Expand All @@ -80,7 +80,7 @@ def test_lambert_conformal_transform():
E = 567623.931
N = 256422.787
h = 1341.467
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
Long1, Lat1, H1 = pyproj.transform(Midelt, WGS84, E, N, h, radians=False)
assert_almost_equal((Long1, Lat1, H1), (-4.6753456, 32.902199, 1341.467), decimal=5)

Expand Down Expand Up @@ -114,7 +114,7 @@ def test_4d_transform_crs_obs1():


def test_4d_transform_orginal_crs_obs1():
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
assert_almost_equal(
transform(
7789, 8401, x=3496737.2679, y=743254.4507, z=5264462.9620, tt=2019.0
Expand Down Expand Up @@ -142,7 +142,7 @@ def test_2d_with_time_transform_crs_obs2():


def test_2d_with_time_transform_original_crs_obs2():
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
assert_almost_equal(
transform(4896, 7930, x=3496737.2679, y=743254.4507, tt=2019.0),
(3496737.4105305015, 743254.1014318303, 2019.0),
Expand Down Expand Up @@ -174,7 +174,7 @@ def test_3d_time_itransform():


def test_4d_itransform_orginal_crs_obs1():
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
assert_almost_equal(
list(
itransform(
Expand All @@ -186,7 +186,7 @@ def test_4d_itransform_orginal_crs_obs1():


def test_2d_with_time_itransform_original_crs_obs2():
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
assert_almost_equal(
list(
itransform(
Expand All @@ -199,7 +199,7 @@ def test_2d_with_time_itransform_original_crs_obs2():

def test_itransform_time_3rd_invalid():

with pytest.warns(DeprecationWarning), pytest.raises(
with pytest.warns(FutureWarning), pytest.raises(
ValueError, match="'time_3rd' is only valid for 3 coordinates."
):
list(
Expand All @@ -210,7 +210,7 @@ def test_itransform_time_3rd_invalid():
time_3rd=True,
)
)
with pytest.warns(DeprecationWarning), pytest.raises(
with pytest.warns(FutureWarning), pytest.raises(
ValueError, match="'time_3rd' is only valid for 3 coordinates."
):
list(itransform(7789, 8401, [(3496737.2679, 743254.4507)], time_3rd=True))
Expand All @@ -220,15 +220,15 @@ def test_transform_no_error():
with pytest.warns(FutureWarning):
pj = Proj(init="epsg:4555")
pjx, pjy = pj(116.366, 39.867)
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
transform(pj, Proj(4326), pjx, pjy, radians=True, errcheck=True)


def test_itransform_no_error():
with pytest.warns(FutureWarning):
pj = Proj(init="epsg:4555")
pjx, pjy = pj(116.366, 39.867)
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
list(itransform(pj, Proj(4326), [(pjx, pjy)], radians=True, errcheck=True))


Expand All @@ -251,7 +251,7 @@ def test_transform_radians():
with pytest.warns(FutureWarning):
WGS84 = pyproj.Proj("+init=EPSG:4326")
ECEF = pyproj.Proj(proj="geocent", ellps="WGS84", datum="WGS84")
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
assert_almost_equal(
pyproj.transform(
ECEF, WGS84, -2704026.010, -4253051.810, 3895878.820, radians=True
Expand All @@ -276,7 +276,7 @@ def test_itransform_radians():
with pytest.warns(FutureWarning):
WGS84 = pyproj.Proj("+init=EPSG:4326")
ECEF = pyproj.Proj(proj="geocent", ellps="WGS84", datum="WGS84")
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
assert_almost_equal(
list(
pyproj.itransform(
Expand Down Expand Up @@ -338,15 +338,15 @@ def test_always_xy__transformer():


def test_always_xy__transform():
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
assert_almost_equal(
transform(2193, 4326, 1625350, 5504853, always_xy=True),
(173.29964730317386, -40.60674802693758),
)


def test_always_xy__itransform():
with pytest.warns(DeprecationWarning):
with pytest.warns(FutureWarning):
assert_almost_equal(
list(itransform(2193, 4326, [(1625350, 5504853)], always_xy=True)),
[(173.29964730317386, -40.60674802693758)],
Expand Down

0 comments on commit 837d965

Please sign in to comment.