Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented May 4, 2016

a = pd.Categorical([1, 2, 3, 4])
b = pd.Categorical([1, 2, 3, 5])
tm.assert_categorical_equal(a, b)
# Categorical.categories are different
# ...

a = pd.Categorical([1, 2, 4, 3], categories=[1, 2, 3, 4])
b = pd.Categorical([1, 2, 3, 4], categories=[1, 2, 3, 4])
tm.assert_categorical_equal(a, b)
# Categorical.codes values are different (50.0 %)
# ...

This must be after #13088.

@sinhrks sinhrks added Testing pandas testing functions or related to the test suite Error Reporting Incorrect or improved errors from pandas Categorical Categorical Data Type labels May 4, 2016
@sinhrks sinhrks added this to the 0.18.2 milestone May 4, 2016
@sinhrks sinhrks force-pushed the test_categorical_message branch from 35f1a53 to 1a5cc27 Compare May 4, 2016 05:08
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In [2]: tm.assert_numpy_array_equal(np.array([1,2],dtype='int64'),np.array([1,2],dtype='int8'))
Out[2]: True

check the dtypes are equal as well (in fact we might want to do that in assert_numpy_array_equal)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will split this to other PR as there are lots of failures (unrelated to categorical).

@sinhrks sinhrks force-pushed the test_categorical_message branch 3 times, most recently from ef83608 to ee0f652 Compare May 4, 2016 21:56
@sinhrks sinhrks mentioned this pull request May 5, 2016
3 tasks
@sinhrks sinhrks changed the title TST: fix assert_categorical_equal message (WIP)TST: fix assert_categorical_equal message May 5, 2016
@sinhrks sinhrks force-pushed the test_categorical_message branch 2 times, most recently from 6f48d79 to 91ccb3c Compare May 7, 2016 23:16
@sinhrks sinhrks changed the title (WIP)TST: fix assert_categorical_equal message TST: fix assert_categorical_equal message May 7, 2016
@sinhrks sinhrks force-pushed the test_categorical_message branch from 91ccb3c to 81172ce Compare May 11, 2016 08:43
@@ -985,7 +985,7 @@ def __setstate__(self, state):

# Provide compatibility with pre-0.15.0 Categoricals.
if '_codes' not in state and 'labels' in state:
state['_codes'] = state.pop('labels')
state['_codes'] = state.pop('labels').astype(np.int8)
Copy link
Member Author

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?

@jreback jreback closed this in 2a99394 May 11, 2016
@jreback
Copy link
Contributor

jreback commented May 11, 2016

ty sir!

@sinhrks sinhrks deleted the test_categorical_message branch May 11, 2016 22:43
jreback pushed a commit that referenced this pull request Jul 5, 2016
follow up for #13080 to use `_coerce_indexer_dtype`.

Author: sinhrks <[email protected]>

Closes #13426 from sinhrks/cat_pickle and squashes the following commits:

e8702f8 [sinhrks] BUG: categorical unpickle to use _coerce_indexer_dtype
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type Error Reporting Incorrect or improved errors from pandas Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants