Skip to content

Commit 1a2d03d

Browse files
committed
WARN: remove obsolete warnings
1 parent b7cee4c commit 1a2d03d

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

pandas/core/categorical.py

-14
Original file line numberDiff line numberDiff line change
@@ -358,20 +358,6 @@ def __init__(self, values, categories=None, ordered=None, dtype=None,
358358

359359
codes = _get_codes_for_values(values, dtype.categories)
360360

361-
# TODO: check for old style usage. These warnings should be removes
362-
# after 0.18/ in 2016
363-
if (is_integer_dtype(values) and
364-
not is_integer_dtype(dtype.categories)):
365-
warn("Values and categories have different dtypes. Did you "
366-
"mean to use\n'Categorical.from_codes(codes, "
367-
"categories)'?", RuntimeWarning, stacklevel=2)
368-
369-
if (len(values) and is_integer_dtype(values) and
370-
(codes == -1).all()):
371-
warn("None of the categories were found in values. Did you "
372-
"mean to use\n'Categorical.from_codes(codes, "
373-
"categories)'?", RuntimeWarning, stacklevel=2)
374-
375361
if null_mask.any():
376362
full_codes = - np.ones(null_mask.shape, dtype=codes.dtype)
377363
full_codes[~null_mask] = codes

pandas/tests/test_categorical.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -306,20 +306,19 @@ def f():
306306
assert len(cat.codes) == 1
307307
assert cat.codes[0] == 0
308308

309-
# Catch old style constructor useage: two arrays, codes + categories
310-
# We can only catch two cases:
309+
# Catches - now disabled - for old style constructor useage:
310+
# two arrays, codes + categories
311311
# - when the first is an integer dtype and the second is not
312312
# - when the resulting codes are all -1/NaN
313-
with tm.assert_produces_warning(RuntimeWarning):
313+
with tm.assert_produces_warning(None):
314314
c_old = Categorical([0, 1, 2, 0, 1, 2],
315315
categories=["a", "b", "c"]) # noqa
316316

317-
with tm.assert_produces_warning(RuntimeWarning):
317+
with tm.assert_produces_warning(None):
318318
c_old = Categorical([0, 1, 2, 0, 1, 2], # noqa
319319
categories=[3, 4, 5])
320320

321-
# the next one are from the old docs, but unfortunately these don't
322-
# trigger :-(
321+
# the next one are from the old docs
323322
with tm.assert_produces_warning(None):
324323
c_old2 = Categorical([0, 1, 2, 0, 1, 2], [1, 2, 3]) # noqa
325324
cat = Categorical([1, 2], categories=[1, 2, 3])

0 commit comments

Comments
 (0)