4
4
Literal ,
5
5
cast ,
6
6
)
7
- import warnings
8
7
9
8
import numpy as np
10
9
11
- from pandas ._libs .lib import (
12
- NoDefault ,
13
- no_default ,
14
- )
15
10
from pandas ._libs .missing import is_matching_na
16
11
from pandas ._libs .sparse import SparseIndex
17
12
import pandas ._libs .testing as _testing
18
- from pandas .util ._exceptions import find_stack_level
19
13
20
14
from pandas .core .dtypes .common import (
21
15
is_bool ,
@@ -64,7 +58,6 @@ def assert_almost_equal(
64
58
left ,
65
59
right ,
66
60
check_dtype : bool | Literal ["equiv" ] = "equiv" ,
67
- check_less_precise : bool | int | NoDefault = no_default ,
68
61
rtol : float = 1.0e-5 ,
69
62
atol : float = 1.0e-8 ,
70
63
** kwargs ,
@@ -83,20 +76,6 @@ def assert_almost_equal(
83
76
Check dtype if both a and b are the same type. If 'equiv' is passed in,
84
77
then `RangeIndex` and `Int64Index` are also considered equivalent
85
78
when doing type checking.
86
- check_less_precise : bool or int, default False
87
- Specify comparison precision. 5 digits (False) or 3 digits (True)
88
- after decimal points are compared. If int, then specify the number
89
- of digits to compare.
90
-
91
- When comparing two numbers, if the first number has magnitude less
92
- than 1e-5, we compare the two numbers directly and check whether
93
- they are equivalent within the specified precision. Otherwise, we
94
- compare the **ratio** of the second number to the first number and
95
- check whether it is equivalent to 1 within the specified precision.
96
-
97
- .. deprecated:: 1.1.0
98
- Use `rtol` and `atol` instead to define relative/absolute
99
- tolerance, respectively. Similar to :func:`math.isclose`.
100
79
rtol : float, default 1e-5
101
80
Relative tolerance.
102
81
@@ -106,16 +85,6 @@ def assert_almost_equal(
106
85
107
86
.. versionadded:: 1.1.0
108
87
"""
109
- if check_less_precise is not no_default :
110
- warnings .warn (
111
- "The 'check_less_precise' keyword in testing.assert_*_equal "
112
- "is deprecated and will be removed in a future version. "
113
- "You can stop passing 'check_less_precise' to silence this warning." ,
114
- FutureWarning ,
115
- stacklevel = find_stack_level (),
116
- )
117
- rtol = atol = _get_tol_from_less_precise (check_less_precise )
118
-
119
88
if isinstance (left , Index ):
120
89
assert_index_equal (
121
90
left ,
@@ -171,46 +140,6 @@ def assert_almost_equal(
171
140
)
172
141
173
142
174
- def _get_tol_from_less_precise (check_less_precise : bool | int ) -> float :
175
- """
176
- Return the tolerance equivalent to the deprecated `check_less_precise`
177
- parameter.
178
-
179
- Parameters
180
- ----------
181
- check_less_precise : bool or int
182
-
183
- Returns
184
- -------
185
- float
186
- Tolerance to be used as relative/absolute tolerance.
187
-
188
- Examples
189
- --------
190
- >>> # Using check_less_precise as a bool:
191
- >>> _get_tol_from_less_precise(False)
192
- 5e-06
193
- >>> _get_tol_from_less_precise(True)
194
- 0.0005
195
- >>> # Using check_less_precise as an int representing the decimal
196
- >>> # tolerance intended:
197
- >>> _get_tol_from_less_precise(2)
198
- 0.005
199
- >>> _get_tol_from_less_precise(8)
200
- 5e-09
201
- """
202
- if isinstance (check_less_precise , bool ):
203
- if check_less_precise :
204
- # 3-digit tolerance
205
- return 0.5e-3
206
- else :
207
- # 5-digit tolerance
208
- return 0.5e-5
209
- else :
210
- # Equivalent to setting checking_less_precise=<decimals>
211
- return 0.5 * 10 ** - check_less_precise
212
-
213
-
214
143
def _check_isinstance (left , right , cls ):
215
144
"""
216
145
Helper method for our assert_* methods that ensures that
@@ -250,7 +179,6 @@ def assert_index_equal(
250
179
right : Index ,
251
180
exact : bool | str = "equiv" ,
252
181
check_names : bool = True ,
253
- check_less_precise : bool | int | NoDefault = no_default ,
254
182
check_exact : bool = True ,
255
183
check_categorical : bool = True ,
256
184
check_order : bool = True ,
@@ -271,14 +199,6 @@ def assert_index_equal(
271
199
Int64Index as well.
272
200
check_names : bool, default True
273
201
Whether to check the names attribute.
274
- check_less_precise : bool or int, default False
275
- Specify comparison precision. Only used when check_exact is False.
276
- 5 digits (False) or 3 digits (True) after decimal points are compared.
277
- If int, then specify the digits to compare.
278
-
279
- .. deprecated:: 1.1.0
280
- Use `rtol` and `atol` instead to define relative/absolute
281
- tolerance, respectively. Similar to :func:`math.isclose`.
282
202
check_exact : bool, default True
283
203
Whether to compare number exactly.
284
204
check_categorical : bool, default True
@@ -333,16 +253,6 @@ def _get_ilevel_values(index, level):
333
253
filled = take_nd (unique ._values , level_codes , fill_value = unique ._na_value )
334
254
return unique ._shallow_copy (filled , name = index .names [level ])
335
255
336
- if check_less_precise is not no_default :
337
- warnings .warn (
338
- "The 'check_less_precise' keyword in testing.assert_*_equal "
339
- "is deprecated and will be removed in a future version. "
340
- "You can stop passing 'check_less_precise' to silence this warning." ,
341
- FutureWarning ,
342
- stacklevel = find_stack_level (),
343
- )
344
- rtol = atol = _get_tol_from_less_precise (check_less_precise )
345
-
346
256
# instance validation
347
257
_check_isinstance (left , right , Index )
348
258
@@ -775,7 +685,6 @@ def assert_extension_array_equal(
775
685
right ,
776
686
check_dtype : bool | Literal ["equiv" ] = True ,
777
687
index_values = None ,
778
- check_less_precise = no_default ,
779
688
check_exact : bool = False ,
780
689
rtol : float = 1.0e-5 ,
781
690
atol : float = 1.0e-8 ,
@@ -791,14 +700,6 @@ def assert_extension_array_equal(
791
700
Whether to check if the ExtensionArray dtypes are identical.
792
701
index_values : numpy.ndarray, default None
793
702
Optional index (shared by both left and right), used in output.
794
- check_less_precise : bool or int, default False
795
- Specify comparison precision. Only used when check_exact is False.
796
- 5 digits (False) or 3 digits (True) after decimal points are compared.
797
- If int, then specify the digits to compare.
798
-
799
- .. deprecated:: 1.1.0
800
- Use `rtol` and `atol` instead to define relative/absolute
801
- tolerance, respectively. Similar to :func:`math.isclose`.
802
703
check_exact : bool, default False
803
704
Whether to compare number exactly.
804
705
rtol : float, default 1e-5
@@ -823,16 +724,6 @@ def assert_extension_array_equal(
823
724
>>> b, c = a.array, a.array
824
725
>>> tm.assert_extension_array_equal(b, c)
825
726
"""
826
- if check_less_precise is not no_default :
827
- warnings .warn (
828
- "The 'check_less_precise' keyword in testing.assert_*_equal "
829
- "is deprecated and will be removed in a future version. "
830
- "You can stop passing 'check_less_precise' to silence this warning." ,
831
- FutureWarning ,
832
- stacklevel = find_stack_level (),
833
- )
834
- rtol = atol = _get_tol_from_less_precise (check_less_precise )
835
-
836
727
assert isinstance (left , ExtensionArray ), "left is not an ExtensionArray"
837
728
assert isinstance (right , ExtensionArray ), "right is not an ExtensionArray"
838
729
if check_dtype :
@@ -881,7 +772,6 @@ def assert_series_equal(
881
772
check_dtype : bool | Literal ["equiv" ] = True ,
882
773
check_index_type : bool | Literal ["equiv" ] = "equiv" ,
883
774
check_series_type : bool = True ,
884
- check_less_precise : bool | int | NoDefault = no_default ,
885
775
check_names : bool = True ,
886
776
check_exact : bool = False ,
887
777
check_datetimelike_compat : bool = False ,
@@ -910,20 +800,6 @@ def assert_series_equal(
910
800
are identical.
911
801
check_series_type : bool, default True
912
802
Whether to check the Series class is identical.
913
- check_less_precise : bool or int, default False
914
- Specify comparison precision. Only used when check_exact is False.
915
- 5 digits (False) or 3 digits (True) after decimal points are compared.
916
- If int, then specify the digits to compare.
917
-
918
- When comparing two numbers, if the first number has magnitude less
919
- than 1e-5, we compare the two numbers directly and check whether
920
- they are equivalent within the specified precision. Otherwise, we
921
- compare the **ratio** of the second number to the first number and
922
- check whether it is equivalent to 1 within the specified precision.
923
-
924
- .. deprecated:: 1.1.0
925
- Use `rtol` and `atol` instead to define relative/absolute
926
- tolerance, respectively. Similar to :func:`math.isclose`.
927
803
check_names : bool, default True
928
804
Whether to check the Series and Index names attribute.
929
805
check_exact : bool, default False
@@ -978,16 +854,6 @@ def assert_series_equal(
978
854
if not check_index and check_like :
979
855
raise ValueError ("check_like must be False if check_index is False" )
980
856
981
- if check_less_precise is not no_default :
982
- warnings .warn (
983
- "The 'check_less_precise' keyword in testing.assert_*_equal "
984
- "is deprecated and will be removed in a future version. "
985
- "You can stop passing 'check_less_precise' to silence this warning." ,
986
- FutureWarning ,
987
- stacklevel = find_stack_level (),
988
- )
989
- rtol = atol = _get_tol_from_less_precise (check_less_precise )
990
-
991
857
# instance validation
992
858
_check_isinstance (left , right , Series )
993
859
@@ -1150,7 +1016,6 @@ def assert_frame_equal(
1150
1016
check_index_type : bool | Literal ["equiv" ] = "equiv" ,
1151
1017
check_column_type : bool | Literal ["equiv" ] = "equiv" ,
1152
1018
check_frame_type : bool = True ,
1153
- check_less_precise = no_default ,
1154
1019
check_names : bool = True ,
1155
1020
by_blocks : bool = False ,
1156
1021
check_exact : bool = False ,
@@ -1188,20 +1053,6 @@ def assert_frame_equal(
1188
1053
:func:`assert_index_equal`.
1189
1054
check_frame_type : bool, default True
1190
1055
Whether to check the DataFrame class is identical.
1191
- check_less_precise : bool or int, default False
1192
- Specify comparison precision. Only used when check_exact is False.
1193
- 5 digits (False) or 3 digits (True) after decimal points are compared.
1194
- If int, then specify the digits to compare.
1195
-
1196
- When comparing two numbers, if the first number has magnitude less
1197
- than 1e-5, we compare the two numbers directly and check whether
1198
- they are equivalent within the specified precision. Otherwise, we
1199
- compare the **ratio** of the second number to the first number and
1200
- check whether it is equivalent to 1 within the specified precision.
1201
-
1202
- .. deprecated:: 1.1.0
1203
- Use `rtol` and `atol` instead to define relative/absolute
1204
- tolerance, respectively. Similar to :func:`math.isclose`.
1205
1056
check_names : bool, default True
1206
1057
Whether to check that the `names` attribute for both the `index`
1207
1058
and `column` attributes of the DataFrame is identical.
@@ -1271,16 +1122,6 @@ def assert_frame_equal(
1271
1122
"""
1272
1123
__tracebackhide__ = True
1273
1124
1274
- if check_less_precise is not no_default :
1275
- warnings .warn (
1276
- "The 'check_less_precise' keyword in testing.assert_*_equal "
1277
- "is deprecated and will be removed in a future version. "
1278
- "You can stop passing 'check_less_precise' to silence this warning." ,
1279
- FutureWarning ,
1280
- stacklevel = find_stack_level (),
1281
- )
1282
- rtol = atol = _get_tol_from_less_precise (check_less_precise )
1283
-
1284
1125
# instance validation
1285
1126
_check_isinstance (left , right , DataFrame )
1286
1127
0 commit comments