@@ -116,18 +116,40 @@ def assertNotAlmostEquals(self, *args, **kwargs):
116
116
117
117
118
118
def assert_almost_equal (left , right , check_exact = False ,
119
- check_dtype = 'equiv' , ** kwargs ):
119
+ check_dtype = 'equiv' , check_less_precise = False ,
120
+ ** kwargs ):
121
+ """Check that left and right Index are equal.
122
+
123
+ Parameters
124
+ ----------
125
+ left : object
126
+ right : object
127
+ check_exact : bool, default True
128
+ Whether to compare number exactly.
129
+ check_dtype: bool, default True
130
+ check dtype if both a and b are the same type
131
+ check_less_precise : bool or int, default False
132
+ Specify comparison precision. Only used when check_exact is False.
133
+ 5 digits (False) or 3 digits (True) after decimal points are compared.
134
+ If int, then specify the digits to compare
135
+ """
120
136
if isinstance (left , pd .Index ):
121
137
return assert_index_equal (left , right , check_exact = check_exact ,
122
- exact = check_dtype , ** kwargs )
138
+ exact = check_dtype ,
139
+ check_less_precise = check_less_precise ,
140
+ ** kwargs )
123
141
124
142
elif isinstance (left , pd .Series ):
125
143
return assert_series_equal (left , right , check_exact = check_exact ,
126
- check_dtype = check_dtype , ** kwargs )
144
+ check_dtype = check_dtype ,
145
+ check_less_precise = check_less_precise ,
146
+ ** kwargs )
127
147
128
148
elif isinstance (left , pd .DataFrame ):
129
149
return assert_frame_equal (left , right , check_exact = check_exact ,
130
- check_dtype = check_dtype , ** kwargs )
150
+ check_dtype = check_dtype ,
151
+ check_less_precise = check_less_precise ,
152
+ ** kwargs )
131
153
132
154
else :
133
155
# other sequences
@@ -142,8 +164,11 @@ def assert_almost_equal(left, right, check_exact=False,
142
164
else :
143
165
obj = 'Input'
144
166
assert_class_equal (left , right , obj = obj )
145
- return _testing .assert_almost_equal (left , right ,
146
- check_dtype = check_dtype , ** kwargs )
167
+ return _testing .assert_almost_equal (
168
+ left , right ,
169
+ check_dtype = check_dtype ,
170
+ check_less_precise = check_less_precise ,
171
+ ** kwargs )
147
172
148
173
149
174
def assert_dict_equal (left , right , compare_keys = True ):
@@ -690,9 +715,10 @@ def assert_index_equal(left, right, exact='equiv', check_names=True,
690
715
Int64Index as well
691
716
check_names : bool, default True
692
717
Whether to check the names attribute.
693
- check_less_precise : bool, default False
718
+ check_less_precise : bool or int , default False
694
719
Specify comparison precision. Only used when check_exact is False.
695
720
5 digits (False) or 3 digits (True) after decimal points are compared.
721
+ If int, then specify the digits to compare
696
722
check_exact : bool, default True
697
723
Whether to compare number exactly.
698
724
check_categorical : bool, default True
@@ -1040,9 +1066,10 @@ def assert_series_equal(left, right, check_dtype=True,
1040
1066
are identical.
1041
1067
check_series_type : bool, default False
1042
1068
Whether to check the Series class is identical.
1043
- check_less_precise : bool, default False
1069
+ check_less_precise : bool or int , default False
1044
1070
Specify comparison precision. Only used when check_exact is False.
1045
1071
5 digits (False) or 3 digits (True) after decimal points are compared.
1072
+ If int, then specify the digits to compare
1046
1073
check_exact : bool, default False
1047
1074
Whether to compare number exactly.
1048
1075
check_names : bool, default True
@@ -1106,7 +1133,7 @@ def assert_series_equal(left, right, check_dtype=True,
1106
1133
check_dtype = check_dtype )
1107
1134
else :
1108
1135
_testing .assert_almost_equal (left .get_values (), right .get_values (),
1109
- check_less_precise ,
1136
+ check_less_precise = check_less_precise ,
1110
1137
check_dtype = check_dtype ,
1111
1138
obj = '{0}' .format (obj ))
1112
1139
@@ -1150,9 +1177,10 @@ def assert_frame_equal(left, right, check_dtype=True,
1150
1177
are identical.
1151
1178
check_frame_type : bool, default False
1152
1179
Whether to check the DataFrame class is identical.
1153
- check_less_precise : bool, default False
1180
+ check_less_precise : bool or it , default False
1154
1181
Specify comparison precision. Only used when check_exact is False.
1155
1182
5 digits (False) or 3 digits (True) after decimal points are compared.
1183
+ If int, then specify the digits to compare
1156
1184
check_names : bool, default True
1157
1185
Whether to check the Index names attribute.
1158
1186
by_blocks : bool, default False
@@ -1259,9 +1287,10 @@ def assert_panelnd_equal(left, right,
1259
1287
Whether to check the Panel dtype is identical.
1260
1288
check_panel_type : bool, default False
1261
1289
Whether to check the Panel class is identical.
1262
- check_less_precise : bool, default False
1290
+ check_less_precise : bool or int , default False
1263
1291
Specify comparison precision. Only used when check_exact is False.
1264
1292
5 digits (False) or 3 digits (True) after decimal points are compared.
1293
+ If int, then specify the digits to compare
1265
1294
assert_func : function for comparing data
1266
1295
check_names : bool, default True
1267
1296
Whether to check the Index names attribute.
0 commit comments