Skip to content

Commit 5bcf6f6

Browse files
committed
Use "msg" not "err"
1 parent f294147 commit 5bcf6f6

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

pandas/core/arrays/categorical.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -632,18 +632,16 @@ def from_codes(cls, codes, categories, ordered=False):
632632
"""
633633
codes = np.asarray(codes)
634634
if not is_integer_dtype(codes):
635-
err = True
635+
msg = "codes need to be array-like integers"
636636
if is_float_dtype(codes):
637637
icodes = codes.astype('i8')
638638
if (icodes == codes).all():
639-
err = False
639+
msg = None
640640
codes = icodes
641-
warn("float codes will be disallowed in the future",
642-
FutureWarning, stacklevel=2)
643-
else:
644-
err = True
645-
if err:
646-
raise ValueError("codes need to be array-like integers")
641+
warn(("float codes will be disallowed in the future and "
642+
"raise a ValueError"), FutureWarning, stacklevel=2)
643+
if msg:
644+
raise ValueError(msg)
647645

648646
try:
649647
codes = coerce_indexer_dtype(codes, categories)

0 commit comments

Comments
 (0)