Skip to content

Commit 0051281

Browse files
committed
Address comments from jreback
1 parent 2d77edb commit 0051281

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pandas/tests/categorical/test_constructors.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import pytest
44
from datetime import datetime
5-
import warnings
65

76
import numpy as np
87

@@ -474,12 +473,15 @@ def test_from_codes_with_nan_code(self):
474473

475474
def test_from_codes_with_float(self):
476475
# GH21767
477-
codes = [1.0, 2.0, 0]
476+
codes = [1.0, 2.0, 0] # integer, but in float dtype
478477
categories = ['a', 'b', 'c']
479-
with warnings.catch_warnings(record=True) as w:
478+
479+
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
480480
Categorical.from_codes(codes, categories)
481481

482-
assert len(w) == 1
482+
codes = [1.1, 2.0, 0] # non-integer
483+
with pytest.raises(ValueError):
484+
Categorical.from_codes(codes, categories)
483485

484486
@pytest.mark.parametrize('dtype', [None, 'category'])
485487
def test_from_inferred_categories(self, dtype):

0 commit comments

Comments
 (0)