|
16 | 16 |
|
17 | 17 | from pandas.core.dtypes.common import (
|
18 | 18 | is_bool,
|
| 19 | + is_float_dtype, |
19 | 20 | is_integer_dtype,
|
20 | 21 | is_number,
|
21 | 22 | is_numeric_dtype,
|
@@ -713,7 +714,7 @@ def assert_extension_array_equal(
|
713 | 714 | index_values : Index | numpy.ndarray, default None
|
714 | 715 | Optional index (shared by both left and right), used in output.
|
715 | 716 | check_exact : bool, default False
|
716 |
| - Whether to compare number exactly. |
| 717 | + Whether to compare number exactly. Only takes effect for float dtypes. |
717 | 718 | rtol : float, default 1e-5
|
718 | 719 | Relative tolerance. Only used when check_exact is False.
|
719 | 720 | atol : float, default 1e-8
|
@@ -782,7 +783,10 @@ def assert_extension_array_equal(
|
782 | 783 |
|
783 | 784 | left_valid = left[~left_na].to_numpy(dtype=object)
|
784 | 785 | right_valid = right[~right_na].to_numpy(dtype=object)
|
785 |
| - if check_exact: |
| 786 | + if check_exact or ( |
| 787 | + (is_numeric_dtype(left.dtype) and not is_float_dtype(left.dtype)) |
| 788 | + or (is_numeric_dtype(right.dtype) and not is_float_dtype(right.dtype)) |
| 789 | + ): |
786 | 790 | assert_numpy_array_equal(
|
787 | 791 | left_valid, right_valid, obj=obj, index_values=index_values
|
788 | 792 | )
|
@@ -836,7 +840,7 @@ def assert_series_equal(
|
836 | 840 | check_names : bool, default True
|
837 | 841 | Whether to check the Series and Index names attribute.
|
838 | 842 | check_exact : bool, default False
|
839 |
| - Whether to compare number exactly. |
| 843 | + Whether to compare number exactly. Only takes effect for float dtypes. |
840 | 844 | check_datetimelike_compat : bool, default False
|
841 | 845 | Compare datetime-like which is comparable ignoring dtype.
|
842 | 846 | check_categorical : bool, default True
|
@@ -929,8 +933,10 @@ def assert_series_equal(
|
929 | 933 | pass
|
930 | 934 | else:
|
931 | 935 | assert_attr_equal("dtype", left, right, obj=f"Attributes of {obj}")
|
932 |
| - |
933 |
| - if check_exact and is_numeric_dtype(left.dtype) and is_numeric_dtype(right.dtype): |
| 936 | + if check_exact or ( |
| 937 | + (is_numeric_dtype(left.dtype) and not is_float_dtype(left.dtype)) |
| 938 | + or (is_numeric_dtype(right.dtype) and not is_float_dtype(right.dtype)) |
| 939 | + ): |
934 | 940 | left_values = left._values
|
935 | 941 | right_values = right._values
|
936 | 942 | # Only check exact if dtype is numeric
|
@@ -1093,7 +1099,7 @@ def assert_frame_equal(
|
1093 | 1099 | Specify how to compare internal data. If False, compare by columns.
|
1094 | 1100 | If True, compare by blocks.
|
1095 | 1101 | check_exact : bool, default False
|
1096 |
| - Whether to compare number exactly. |
| 1102 | + Whether to compare number exactly. Only takes effect for float dtypes. |
1097 | 1103 | check_datetimelike_compat : bool, default False
|
1098 | 1104 | Compare datetime-like which is comparable ignoring dtype.
|
1099 | 1105 | check_categorical : bool, default True
|
|
0 commit comments