From 8a42c9cca2132ef6f6a17014e59513da05a9acb7 Mon Sep 17 00:00:00 2001 From: snowman2 Date: Sat, 2 May 2020 12:08:24 -0500 Subject: [PATCH] Add warning for radians flag with Proj class --- pyproj/_transformer.pyx | 4 ++-- pyproj/proj.py | 11 +++++++++++ pyproj/transformer.py | 2 +- test/test_proj.py | 6 ++++++ test/test_transformer.py | 2 +- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/pyproj/_transformer.pyx b/pyproj/_transformer.pyx index a8491598c..8b7d973a0 100644 --- a/pyproj/_transformer.pyx +++ b/pyproj/_transformer.pyx @@ -424,8 +424,8 @@ cdef class _Transformer(Base): return if radians and self.is_pipeline: warnings.warn( - "radian input with pipelines is not supported and may result " - "in unexpected transformations." + "radian input with pipelines is not supported in pyproj 2. " + "support for raidans will be added in pyproj 3." ) tmp_pj_direction = _PJ_DIRECTION_MAP[TransformDirection.create(direction)] diff --git a/pyproj/proj.py b/pyproj/proj.py index 048af0c0d..3f71cd823 100644 --- a/pyproj/proj.py +++ b/pyproj/proj.py @@ -137,6 +137,7 @@ def __call__( latitude: Any, inverse: bool = False, errcheck: bool = False, + radians: bool = False, ) -> Tuple[Any, Any]: """ Calling a Proj class instance with the arguments lon, lat will @@ -158,6 +159,11 @@ def __call__( inverse: boolean, optional If inverse is True the inverse transformation from x/y to lon/lat is performed. Default is False. + radians: boolean, optional + If True, will expect input data to be in radians and will return radians + if the projection is geographic. Default is False (degrees). + This does not work with pyproj 2 and is ignored. It will be enabled again + in pyproj 3. errcheck: boolean, optional If True an exception is raised if the errors are found in the process. By default errcheck=False and ``inf`` is returned. @@ -167,6 +173,11 @@ def __call__( Tuple[Any, Any]: The transformed coordinates. """ + if radians: + warnings.warn( + "radian input is currently not supported in pyproj 2. " + "Support for radian input will be added in pyproj 3." + ) # process inputs, making copies that support buffer API. inx, xisfloat, xislist, xistuple = _copytobuffer(longitude) iny, yisfloat, yislist, yistuple = _copytobuffer(latitude) diff --git a/pyproj/transformer.py b/pyproj/transformer.py index 3d9e1d589..c923fc788 100644 --- a/pyproj/transformer.py +++ b/pyproj/transformer.py @@ -363,7 +363,7 @@ def transform( radians: boolean, optional If True, will expect input data to be in radians and will return radians if the projection is geographic. Default is False (degrees). Ignored for - pipeline transformations. + pipeline transformations with pyproj 2, but will work in pyproj 3. errcheck: boolean, optional If True an exception is raised if the transformation is invalid. By default errcheck=False and an invalid transformation diff --git a/test/test_proj.py b/test/test_proj.py index 3bac6ac9a..6d6288522 100644 --- a/test/test_proj.py +++ b/test/test_proj.py @@ -522,3 +522,9 @@ def test_numpy_bool_kwarg_true(): proj="utm", zone=32, ellipsis="WGS84", datum="WGS84", units="m", south=south ) assert "+south " in proj.srs + + +def test_proj_radians_warning(): + proj = Proj("epsg:4326") + with pytest.warns(UserWarning, match="radian"): + proj(1, 2, radians=True) diff --git a/test/test_transformer.py b/test/test_transformer.py index 85314a9da..385c5a9d3 100644 --- a/test/test_transformer.py +++ b/test/test_transformer.py @@ -738,5 +738,5 @@ def test_pipeline_itransform(pipeline_str): def test_pipeline_radian_transform_warning(): trans = Transformer.from_pipeline("+proj=pipeline +ellps=GRS80 +step +proj=cart") - with pytest.warns(UserWarning): + with pytest.warns(UserWarning, match="radian"): trans.transform(0.1, 0.1, 0, radians=True)