@@ -279,6 +279,7 @@ def assert_almost_equal(
279
279
right ,
280
280
check_dtype : Union [bool , str ] = "equiv" ,
281
281
check_less_precise : Union [bool , int ] = False ,
282
+ check_low_values : bool = False ,
282
283
** kwargs ,
283
284
):
284
285
"""
@@ -305,6 +306,9 @@ def assert_almost_equal(
305
306
they are equivalent within the specified precision. Otherwise, we
306
307
compare the **ratio** of the second number to the first number and
307
308
check whether it is equivalent to 1 within the specified precision.
309
+ check_low_values : bool, default False
310
+ Use absolute comparison precision, instead of relative. This is
311
+ particularly useful when comparing values between -1 and 1.
308
312
"""
309
313
if isinstance (left , pd .Index ):
310
314
assert_index_equal (
@@ -313,6 +317,7 @@ def assert_almost_equal(
313
317
check_exact = False ,
314
318
exact = check_dtype ,
315
319
check_less_precise = check_less_precise ,
320
+ check_low_values = check_low_values ,
316
321
** kwargs ,
317
322
)
318
323
@@ -323,6 +328,7 @@ def assert_almost_equal(
323
328
check_exact = False ,
324
329
check_dtype = check_dtype ,
325
330
check_less_precise = check_less_precise ,
331
+ check_low_values = check_low_values ,
326
332
** kwargs ,
327
333
)
328
334
@@ -333,6 +339,7 @@ def assert_almost_equal(
333
339
check_exact = False ,
334
340
check_dtype = check_dtype ,
335
341
check_less_precise = check_less_precise ,
342
+ check_low_values = check_low_values ,
336
343
** kwargs ,
337
344
)
338
345
@@ -356,6 +363,7 @@ def assert_almost_equal(
356
363
right ,
357
364
check_dtype = check_dtype ,
358
365
check_less_precise = check_less_precise ,
366
+ check_low_values = check_low_values ,
359
367
** kwargs ,
360
368
)
361
369
@@ -570,6 +578,7 @@ def assert_index_equal(
570
578
exact : Union [bool , str ] = "equiv" ,
571
579
check_names : bool = True ,
572
580
check_less_precise : Union [bool , int ] = False ,
581
+ check_low_values : bool = False ,
573
582
check_exact : bool = True ,
574
583
check_categorical : bool = True ,
575
584
obj : str = "Index" ,
@@ -591,6 +600,9 @@ def assert_index_equal(
591
600
Specify comparison precision. Only used when check_exact is False.
592
601
5 digits (False) or 3 digits (True) after decimal points are compared.
593
602
If int, then specify the digits to compare.
603
+ check_low_values : bool, default False
604
+ Use absolute comparison precision, instead of relative. This is
605
+ particularly useful when comparing values between -1 and 1.
594
606
check_exact : bool, default True
595
607
Whether to compare number exactly.
596
608
check_categorical : bool, default True
@@ -660,6 +672,7 @@ def _get_ilevel_values(index, level):
660
672
exact = exact ,
661
673
check_names = check_names ,
662
674
check_less_precise = check_less_precise ,
675
+ check_low_values = check_low_values ,
663
676
check_exact = check_exact ,
664
677
obj = lobj ,
665
678
)
@@ -677,6 +690,7 @@ def _get_ilevel_values(index, level):
677
690
left .values ,
678
691
right .values ,
679
692
check_less_precise = check_less_precise ,
693
+ check_low_values = check_low_values ,
680
694
check_dtype = exact ,
681
695
obj = obj ,
682
696
lobj = left ,
@@ -989,7 +1003,12 @@ def _raise(left, right, err_msg):
989
1003
990
1004
991
1005
def assert_extension_array_equal (
992
- left , right , check_dtype = True , check_less_precise = False , check_exact = False
1006
+ left ,
1007
+ right ,
1008
+ check_dtype = True ,
1009
+ check_less_precise = False ,
1010
+ check_low_values = False ,
1011
+ check_exact = False ,
993
1012
):
994
1013
"""Check that left and right ExtensionArrays are equal.
995
1014
@@ -1003,6 +1022,9 @@ def assert_extension_array_equal(
1003
1022
Specify comparison precision. Only used when check_exact is False.
1004
1023
5 digits (False) or 3 digits (True) after decimal points are compared.
1005
1024
If int, then specify the digits to compare.
1025
+ check_low_values : bool, default False
1026
+ Use absolute comparison precision, instead of relative. This is
1027
+ particularly useful when comparing values between -1 and 1.
1006
1028
check_exact : bool, default False
1007
1029
Whether to compare number exactly.
1008
1030
@@ -1036,6 +1058,7 @@ def assert_extension_array_equal(
1036
1058
right_valid ,
1037
1059
check_dtype = check_dtype ,
1038
1060
check_less_precise = check_less_precise ,
1061
+ check_low_values = check_low_values ,
1039
1062
obj = "ExtensionArray" ,
1040
1063
)
1041
1064
@@ -1048,6 +1071,7 @@ def assert_series_equal(
1048
1071
check_index_type = "equiv" ,
1049
1072
check_series_type = True ,
1050
1073
check_less_precise = False ,
1074
+ check_low_values = False ,
1051
1075
check_names = True ,
1052
1076
check_exact = False ,
1053
1077
check_datetimelike_compat = False ,
@@ -1078,6 +1102,9 @@ def assert_series_equal(
1078
1102
they are equivalent within the specified precision. Otherwise, we
1079
1103
compare the **ratio** of the second number to the first number and
1080
1104
check whether it is equivalent to 1 within the specified precision.
1105
+ check_low_values : bool, default False
1106
+ Use absolute comparison precision, instead of relative. This is
1107
+ particularly useful when comparing values between -1 and 1.
1081
1108
check_names : bool, default True
1082
1109
Whether to check the Series and Index names attribute.
1083
1110
check_exact : bool, default False
@@ -1114,6 +1141,7 @@ def assert_series_equal(
1114
1141
exact = check_index_type ,
1115
1142
check_names = check_names ,
1116
1143
check_less_precise = check_less_precise ,
1144
+ check_low_values = check_low_values ,
1117
1145
check_exact = check_exact ,
1118
1146
check_categorical = check_categorical ,
1119
1147
obj = f"{ obj } .index" ,
@@ -1178,6 +1206,7 @@ def assert_series_equal(
1178
1206
left ._internal_get_values (),
1179
1207
right ._internal_get_values (),
1180
1208
check_less_precise = check_less_precise ,
1209
+ check_low_values = check_low_values ,
1181
1210
check_dtype = check_dtype ,
1182
1211
obj = str (obj ),
1183
1212
)
@@ -1200,6 +1229,7 @@ def assert_frame_equal(
1200
1229
check_column_type = "equiv" ,
1201
1230
check_frame_type = True ,
1202
1231
check_less_precise = False ,
1232
+ check_low_values = False ,
1203
1233
check_names = True ,
1204
1234
by_blocks = False ,
1205
1235
check_exact = False ,
@@ -1243,6 +1273,9 @@ def assert_frame_equal(
1243
1273
they are equivalent within the specified precision. Otherwise, we
1244
1274
compare the **ratio** of the second number to the first number and
1245
1275
check whether it is equivalent to 1 within the specified precision.
1276
+ check_low_values : bool, default False
1277
+ Use absolute comparison precision, instead of relative. This is
1278
+ particularly useful when comparing values between -1 and 1.
1246
1279
check_names : bool, default True
1247
1280
Whether to check that the `names` attribute for both the `index`
1248
1281
and `column` attributes of the DataFrame is identical.
@@ -1321,6 +1354,7 @@ def assert_frame_equal(
1321
1354
exact = check_index_type ,
1322
1355
check_names = check_names ,
1323
1356
check_less_precise = check_less_precise ,
1357
+ check_low_values = check_low_values ,
1324
1358
check_exact = check_exact ,
1325
1359
check_categorical = check_categorical ,
1326
1360
obj = f"{ obj } .index" ,
@@ -1333,6 +1367,7 @@ def assert_frame_equal(
1333
1367
exact = check_column_type ,
1334
1368
check_names = check_names ,
1335
1369
check_less_precise = check_less_precise ,
1370
+ check_low_values = check_low_values ,
1336
1371
check_exact = check_exact ,
1337
1372
check_categorical = check_categorical ,
1338
1373
obj = f"{ obj } .columns" ,
@@ -1361,6 +1396,7 @@ def assert_frame_equal(
1361
1396
check_dtype = check_dtype ,
1362
1397
check_index_type = check_index_type ,
1363
1398
check_less_precise = check_less_precise ,
1399
+ check_low_values = check_low_values ,
1364
1400
check_exact = check_exact ,
1365
1401
check_names = check_names ,
1366
1402
check_datetimelike_compat = check_datetimelike_compat ,
0 commit comments