def assert_categorical_equal(left, right, check_dtype=True, obj='Categorical', check_category_order=True):
 assertIsInstance(left, pd.Categorical, '[Categorical] ')
 assertIsInstance(right, pd.Categorical, '[Categorical] ')
 if check_category_order:
  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))
 else:
  assert_index_equal(left.categories.sort_values(), right.categories.sort_values(), obj='{0}.categories'.format(obj))
  assert_index_equal(left.categories.take(left.codes), right.categories.take(right.codes), obj='{0}.values'.format(obj))
 assert_attr_equal('ordered', left, right, obj=obj)

def assert_categorical_equal ( left , right , check_dtype = True , obj = 'Categorical' , check_category_order = True ) : assertIsInstance ( left , pd . Categorical , '[Categorical] ' ) assertIsInstance ( right , pd . Categorical , '[Categorical] ' ) if check_category_order : 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 ) ) else : assert_index_equal ( left . categories . sort_values ( ) , right . categories . sort_values ( ) , obj = '{0}.categories' . format ( obj ) ) assert_index_equal ( left . categories . take ( left . codes ) , right . categories . take ( right . codes ) , obj = '{0}.values' . format ( obj ) ) assert_attr_equal ( 'ordered' , left , right , obj = obj )
test that categoricals are eqivalent parameters left .