Skip to content

Commit ab47916

Browse files
author
eric
committed
PR review for deprecating keyword, order, from factorize().
- Change none to None in docs. - Change warning message to be consistent with other phrasing. - Add tests to catch FutureWarning when order keyword is passed to factorize.
1 parent 261044a commit ab47916

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pandas/tests/test_algos.py

+7
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,13 @@ def test_uint64_factorize(self):
248248
tm.assert_numpy_array_equal(labels, exp_labels)
249249
tm.assert_numpy_array_equal(uniques, exp_uniques)
250250

251+
def test_deprecate_order(self):
252+
data = np.array([2**63, 1, 2**63], dtype=np.uint64)
253+
with tm.assert_produces_warning(expected_warning=FutureWarning):
254+
algos.factorize(data, order=True)
255+
with tm.assert_produces_warning(False):
256+
algos.factorize(data)
257+
251258

252259
class TestUnique(object):
253260

pandas/util/_decorators.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def deprecate_kwarg(old_arg_name, new_arg_name, mapping=None, stacklevel=2):
6666
old_arg_name : str
6767
Name of argument in function to deprecate
6868
new_arg_name : str | None
69-
Name of preferred argument in function. Use none to raise warning that
69+
Name of preferred argument in function. Use None to raise warning that
7070
``old_arg_name`` keyword is deprecated.
7171
mapping : dict or callable
7272
If mapping is present, use it to translate old arguments to
@@ -111,7 +111,8 @@ def wrapper(*args, **kwargs):
111111

112112
if new_arg_name is None and old_arg_value is not None:
113113
msg = (
114-
"the '{old_name}' keyword is no longer supported"
114+
"the '{old_name}' keyword is deprecated and will be"
115+
"removed in a future version"
115116
"please takes steps to stop use of '{old_name}'"
116117
).format(old_name=old_arg_name)
117118
warnings.warn(msg, FutureWarning, stacklevel=stacklevel)

0 commit comments

Comments
 (0)