Skip to content

Commit

Permalink
improve test output for Categoricals (pandas-dev#18069)
Browse files Browse the repository at this point in the history
  • Loading branch information
topper-123 authored and 1kastner committed Nov 5, 2017
1 parent 8844b2e commit 62695a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion doc/source/whatsnew/v0.21.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ Categorical
^^^^^^^^^^^

- Bug in :meth:`DataFrame.astype` where casting to 'category' on an empty ``DataFrame`` causes a segmentation fault (:issue:`18004`)
-
- Error messages in the testing module have been improved when items have
different ``CategoricalDtype`` (:issue:`18069`)
-

Other
Expand Down
4 changes: 4 additions & 0 deletions pandas/util/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,8 +1074,12 @@ def assert_categorical_equal(left, right, check_dtype=True,
def raise_assert_detail(obj, message, left, right, diff=None):
if isinstance(left, np.ndarray):
left = pprint_thing(left)
elif is_categorical_dtype(left):
left = repr(left)
if isinstance(right, np.ndarray):
right = pprint_thing(right)
elif is_categorical_dtype(right):
right = repr(right)

msg = """{obj} are different
Expand Down

0 comments on commit 62695a2

Please sign in to comment.