44 Literal ,
55 cast ,
66)
7- import warnings
87
98import numpy as np
109
11- from pandas ._libs .lib import (
12- NoDefault ,
13- no_default ,
14- )
1510from pandas ._libs .missing import is_matching_na
1611from pandas ._libs .sparse import SparseIndex
1712import pandas ._libs .testing as _testing
18- from pandas .util ._exceptions import find_stack_level
1913
2014from pandas .core .dtypes .common import (
2115 is_bool ,
@@ -64,7 +58,6 @@ def assert_almost_equal(
6458 left ,
6559 right ,
6660 check_dtype : bool | Literal ["equiv" ] = "equiv" ,
67- check_less_precise : bool | int | NoDefault = no_default ,
6861 rtol : float = 1.0e-5 ,
6962 atol : float = 1.0e-8 ,
7063 ** kwargs ,
@@ -83,20 +76,6 @@ def assert_almost_equal(
8376 Check dtype if both a and b are the same type. If 'equiv' is passed in,
8477 then `RangeIndex` and `Int64Index` are also considered equivalent
8578 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`.
10079 rtol : float, default 1e-5
10180 Relative tolerance.
10281
@@ -106,16 +85,6 @@ def assert_almost_equal(
10685
10786 .. versionadded:: 1.1.0
10887 """
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-
11988 if isinstance (left , Index ):
12089 assert_index_equal (
12190 left ,
@@ -171,46 +140,6 @@ def assert_almost_equal(
171140 )
172141
173142
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-
214143def _check_isinstance (left , right , cls ):
215144 """
216145 Helper method for our assert_* methods that ensures that
@@ -250,7 +179,6 @@ def assert_index_equal(
250179 right : Index ,
251180 exact : bool | str = "equiv" ,
252181 check_names : bool = True ,
253- check_less_precise : bool | int | NoDefault = no_default ,
254182 check_exact : bool = True ,
255183 check_categorical : bool = True ,
256184 check_order : bool = True ,
@@ -271,14 +199,6 @@ def assert_index_equal(
271199 Int64Index as well.
272200 check_names : bool, default True
273201 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`.
282202 check_exact : bool, default True
283203 Whether to compare number exactly.
284204 check_categorical : bool, default True
@@ -333,16 +253,6 @@ def _get_ilevel_values(index, level):
333253 filled = take_nd (unique ._values , level_codes , fill_value = unique ._na_value )
334254 return unique ._shallow_copy (filled , name = index .names [level ])
335255
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-
346256 # instance validation
347257 _check_isinstance (left , right , Index )
348258
@@ -775,7 +685,6 @@ def assert_extension_array_equal(
775685 right ,
776686 check_dtype : bool | Literal ["equiv" ] = True ,
777687 index_values = None ,
778- check_less_precise = no_default ,
779688 check_exact : bool = False ,
780689 rtol : float = 1.0e-5 ,
781690 atol : float = 1.0e-8 ,
@@ -791,14 +700,6 @@ def assert_extension_array_equal(
791700 Whether to check if the ExtensionArray dtypes are identical.
792701 index_values : numpy.ndarray, default None
793702 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`.
802703 check_exact : bool, default False
803704 Whether to compare number exactly.
804705 rtol : float, default 1e-5
@@ -823,16 +724,6 @@ def assert_extension_array_equal(
823724 >>> b, c = a.array, a.array
824725 >>> tm.assert_extension_array_equal(b, c)
825726 """
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-
836727 assert isinstance (left , ExtensionArray ), "left is not an ExtensionArray"
837728 assert isinstance (right , ExtensionArray ), "right is not an ExtensionArray"
838729 if check_dtype :
@@ -881,7 +772,6 @@ def assert_series_equal(
881772 check_dtype : bool | Literal ["equiv" ] = True ,
882773 check_index_type : bool | Literal ["equiv" ] = "equiv" ,
883774 check_series_type : bool = True ,
884- check_less_precise : bool | int | NoDefault = no_default ,
885775 check_names : bool = True ,
886776 check_exact : bool = False ,
887777 check_datetimelike_compat : bool = False ,
@@ -910,20 +800,6 @@ def assert_series_equal(
910800 are identical.
911801 check_series_type : bool, default True
912802 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`.
927803 check_names : bool, default True
928804 Whether to check the Series and Index names attribute.
929805 check_exact : bool, default False
@@ -978,16 +854,6 @@ def assert_series_equal(
978854 if not check_index and check_like :
979855 raise ValueError ("check_like must be False if check_index is False" )
980856
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-
991857 # instance validation
992858 _check_isinstance (left , right , Series )
993859
@@ -1150,7 +1016,6 @@ def assert_frame_equal(
11501016 check_index_type : bool | Literal ["equiv" ] = "equiv" ,
11511017 check_column_type : bool | Literal ["equiv" ] = "equiv" ,
11521018 check_frame_type : bool = True ,
1153- check_less_precise = no_default ,
11541019 check_names : bool = True ,
11551020 by_blocks : bool = False ,
11561021 check_exact : bool = False ,
@@ -1188,20 +1053,6 @@ def assert_frame_equal(
11881053 :func:`assert_index_equal`.
11891054 check_frame_type : bool, default True
11901055 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`.
12051056 check_names : bool, default True
12061057 Whether to check that the `names` attribute for both the `index`
12071058 and `column` attributes of the DataFrame is identical.
@@ -1271,16 +1122,6 @@ def assert_frame_equal(
12711122 """
12721123 __tracebackhide__ = True
12731124
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-
12841125 # instance validation
12851126 _check_isinstance (left , right , DataFrame )
12861127
0 commit comments