Skip to content

Commit b6e173b

Browse files
committed
Address comments from jreback
1 parent a880024 commit b6e173b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pandas/tests/arrays/categorical/test_constructors.py

Lines changed: 6 additions & 4 deletions
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

@@ -478,12 +477,15 @@ def test_from_codes_with_nan_code(self):
478477

479478
def test_from_codes_with_float(self):
480479
# GH21767
481-
codes = [1.0, 2.0, 0]
480+
codes = [1.0, 2.0, 0] # integer, but in float dtype
482481
categories = ['a', 'b', 'c']
483-
with warnings.catch_warnings(record=True) as w:
482+
483+
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
484484
Categorical.from_codes(codes, categories)
485485

486-
assert len(w) == 1
486+
codes = [1.1, 2.0, 0] # non-integer
487+
with pytest.raises(ValueError):
488+
Categorical.from_codes(codes, categories)
487489

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

0 commit comments

Comments
 (0)