@@ -778,8 +778,12 @@ def assert_index_equal(left, right, exact='equiv', check_names=True,
778
778
779
779
def _check_types (l , r , obj = 'Index' ):
780
780
if exact :
781
- assert_class_equal (left , right , exact = exact , obj = obj )
782
- assert_attr_equal ('dtype' , l , r , obj = obj )
781
+ assert_class_equal (l , r , exact = exact , obj = obj )
782
+
783
+ # Skip exact dtype checking when `check_categorical` is False
784
+ if check_categorical :
785
+ assert_attr_equal ('dtype' , l , r , obj = obj )
786
+
783
787
# allow string-like to have different inferred_types
784
788
if l .inferred_type in ('string' , 'unicode' ):
785
789
assert r .inferred_type in ('string' , 'unicode' )
@@ -829,7 +833,8 @@ def _get_ilevel_values(index, level):
829
833
# get_level_values may change dtype
830
834
_check_types (left .levels [level ], right .levels [level ], obj = obj )
831
835
832
- if check_exact :
836
+ # skip exact index checking when `check_categorical` is False
837
+ if check_exact and check_categorical :
833
838
if not left .equals (right ):
834
839
diff = np .sum ((left .values != right .values )
835
840
.astype (int )) * 100.0 / len (left )
@@ -950,23 +955,23 @@ def is_sorted(seq):
950
955
951
956
952
957
def assert_categorical_equal (left , right , check_dtype = True ,
953
- obj = 'Categorical' , check_category_order = True ):
958
+ check_category_order = True , obj = 'Categorical' ):
954
959
"""Test that Categoricals are equivalent.
955
960
956
961
Parameters
957
962
----------
958
- left, right : Categorical
959
- Categoricals to compare
963
+ left : Categorical
964
+ right : Categorical
960
965
check_dtype : bool, default True
961
966
Check that integer dtype of the codes are the same
962
- obj : str, default 'Categorical'
963
- Specify object name being compared, internally used to show appropriate
964
- assertion message
965
967
check_category_order : bool, default True
966
968
Whether the order of the categories should be compared, which
967
969
implies identical integer codes. If False, only the resulting
968
970
values are compared. The ordered attribute is
969
971
checked regardless.
972
+ obj : str, default 'Categorical'
973
+ Specify object name being compared, internally used to show appropriate
974
+ assertion message
970
975
"""
971
976
_check_isinstance (left , right , Categorical )
972
977
@@ -1020,7 +1025,7 @@ def raise_assert_detail(obj, message, left, right, diff=None):
1020
1025
1021
1026
def assert_numpy_array_equal (left , right , strict_nan = False ,
1022
1027
check_dtype = True , err_msg = None ,
1023
- obj = 'numpy array' , check_same = None ):
1028
+ check_same = None , obj = 'numpy array' ):
1024
1029
""" Checks that 'np.ndarray' is equivalent
1025
1030
1026
1031
Parameters
@@ -1033,11 +1038,11 @@ def assert_numpy_array_equal(left, right, strict_nan=False,
1033
1038
check dtype if both a and b are np.ndarray
1034
1039
err_msg : str, default None
1035
1040
If provided, used as assertion message
1041
+ check_same : None|'copy'|'same', default None
1042
+ Ensure left and right refer/do not refer to the same memory area
1036
1043
obj : str, default 'numpy array'
1037
1044
Specify object name being compared, internally used to show appropriate
1038
1045
assertion message
1039
- check_same : None|'copy'|'same', default None
1040
- Ensure left and right refer/do not refer to the same memory area
1041
1046
"""
1042
1047
1043
1048
# instance validation
0 commit comments