-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TST: fix assert_categorical_equal message #13080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -903,18 +903,17 @@ def assertNotIsInstance(obj, cls, msg=''): | |
raise AssertionError(err_msg.format(msg, cls)) | ||
|
||
|
||
def assert_categorical_equal(res, exp): | ||
assertIsInstance(res, pd.Categorical, '[Categorical] ') | ||
assertIsInstance(exp, pd.Categorical, '[Categorical] ') | ||
def assert_categorical_equal(left, right, check_dtype=True, | ||
obj='Categorical'): | ||
assertIsInstance(left, pd.Categorical, '[Categorical] ') | ||
assertIsInstance(right, pd.Categorical, '[Categorical] ') | ||
|
||
assert_index_equal(res.categories, exp.categories) | ||
assert_index_equal(left.categories, right.categories, | ||
obj='{0}.categories'.format(obj)) | ||
assert_numpy_array_equal(left.codes, right.codes, check_dtype=check_dtype, | ||
obj='{0}.codes'.format(obj)) | ||
|
||
if not array_equivalent(res.codes, exp.codes): | ||
raise AssertionError( | ||
'codes not equivalent: {0} vs {1}.'.format(res.codes, exp.codes)) | ||
|
||
if res.ordered != exp.ordered: | ||
raise AssertionError("ordered not the same") | ||
assert_attr_equal('ordered', left, right, obj=obj) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, why didn't this work before? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The change is for better error reporting purpose (The validation is the same). As described in #13076, the check itself is OK but it is not called from Series/Index check, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahh I c, ok then. |
||
|
||
|
||
def raise_assert_detail(obj, message, left, right): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor fix to make
dtype
compat. Needs whatsnew?