Skip to content

Commit fabc410

Browse files
committed
WARN: remove obsolete warnings
1 parent e3a6cf2 commit fabc410

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

pandas/core/categorical.py

-15
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
is_timedelta64_dtype,
2626
is_categorical,
2727
is_categorical_dtype,
28-
is_integer_dtype,
2928
is_list_like, is_sequence,
3029
is_scalar,
3130
is_dict_like)
@@ -358,20 +357,6 @@ def __init__(self, values, categories=None, ordered=None, dtype=None,
358357

359358
codes = _get_codes_for_values(values, dtype.categories)
360359

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-
375360
if null_mask.any():
376361
full_codes = - np.ones(null_mask.shape, dtype=codes.dtype)
377362
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)