Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprecation warnings for get_units_map and get_angular_units_map #608

Merged
merged 1 commit into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pyproj/_list.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include "proj.pxi"

from collections import namedtuple
from enum import IntEnum
import warnings

from pyproj.compat import cstrencode, pystrdecode
from pyproj.enums import PJType
Expand Down Expand Up @@ -74,6 +75,12 @@ def get_units_map():
dict:
Units supported by PROJ
"""
warnings.warn(
"The behavior of 'pyproj.get_units_map' is deprecated "
"and will change in version 3.0.0.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment: it's not very clear what the consequence of this is: what will change? What should the user do instead when seeing this warning?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user really cannot do much here as the change will just happen. The exact change isn't 100% decided, but will definitely be different.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it is maybe a bit too soon to raise a warning? As this will just be confusing, I might think

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I wanted to have something. Not sure if there are going to be any more 2.x releases after this next one.

DeprecationWarning,
stacklevel=2,
)
cdef PJ_UNITS *proj_units = proj_list_units()
cdef int iii = 0
units_map = {}
Expand All @@ -95,6 +102,13 @@ def get_angular_units_map():
dict:
Angular units supported by PROJ
"""
warnings.warn(
"'pyproj.get_angular_units_map' is deprecated. "
"Angular units will be available "
"in 'pyproj.get_units_map' in version 3.0.0.",
DeprecationWarning,
stacklevel=2,
)
cdef PJ_UNITS *proj_units = proj_list_angular_units()
cdef int iii = 0
units_map = {}
Expand Down
6 changes: 4 additions & 2 deletions test/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@


def test_units_map():
units_map = get_units_map()
with pytest.warns(DeprecationWarning):
units_map = get_units_map()
assert isinstance(units_map["m"], Unit)
assert units_map["m"].id == "m"
assert units_map["m"].name == "Meter"


def test_angular_units_map():
ang_map = get_angular_units_map()
with pytest.warns(DeprecationWarning):
ang_map = get_angular_units_map()
assert isinstance(ang_map["deg"], Unit)
assert ang_map["deg"].id == "deg"
assert ang_map["deg"].name == "Degree"
Expand Down