|
7 | 7 | NoReturn, |
8 | 8 | cast, |
9 | 9 | ) |
| 10 | +import warnings |
10 | 11 |
|
11 | 12 | import numpy as np |
12 | 13 |
|
|
15 | 16 | from pandas._libs.sparse import SparseIndex |
16 | 17 | import pandas._libs.testing as _testing |
17 | 18 | from pandas._libs.tslibs.np_datetime import compare_mismatched_resolutions |
| 19 | +from pandas.errors import Pandas4Warning |
| 20 | +from pandas.util._decorators import deprecate_kwarg |
18 | 21 |
|
19 | 22 | from pandas.core.dtypes.common import ( |
20 | 23 | is_bool, |
@@ -843,6 +846,7 @@ def assert_extension_array_equal( |
843 | 846 |
|
844 | 847 |
|
845 | 848 | # This could be refactored to use the NDFrame.equals method |
| 849 | +@deprecate_kwarg(Pandas4Warning, "check_datetimelike_compat", new_arg_name=None) |
846 | 850 | def assert_series_equal( |
847 | 851 | left, |
848 | 852 | right, |
@@ -897,6 +901,9 @@ def assert_series_equal( |
897 | 901 |
|
898 | 902 | check_datetimelike_compat : bool, default False |
899 | 903 | Compare datetime-like which is comparable ignoring dtype. |
| 904 | +
|
| 905 | + .. deprecated:: 3.0 |
| 906 | +
|
900 | 907 | check_categorical : bool, default True |
901 | 908 | Whether to compare internal Categorical exactly. |
902 | 909 | check_category_order : bool, default True |
@@ -1132,6 +1139,7 @@ def assert_series_equal( |
1132 | 1139 |
|
1133 | 1140 |
|
1134 | 1141 | # This could be refactored to use the NDFrame.equals method |
| 1142 | +@deprecate_kwarg(Pandas4Warning, "check_datetimelike_compat", new_arg_name=None) |
1135 | 1143 | def assert_frame_equal( |
1136 | 1144 | left, |
1137 | 1145 | right, |
@@ -1194,6 +1202,9 @@ def assert_frame_equal( |
1194 | 1202 | ``check_exact``, ``rtol`` and ``atol`` are specified. |
1195 | 1203 | check_datetimelike_compat : bool, default False |
1196 | 1204 | Compare datetime-like which is comparable ignoring dtype. |
| 1205 | +
|
| 1206 | + .. deprecated:: 3.0 |
| 1207 | +
|
1197 | 1208 | check_categorical : bool, default True |
1198 | 1209 | Whether to compare internal Categorical exactly. |
1199 | 1210 | check_like : bool, default False |
@@ -1320,22 +1331,28 @@ def assert_frame_equal( |
1320 | 1331 | # use check_index=False, because we do not want to run |
1321 | 1332 | # assert_index_equal for each column, |
1322 | 1333 | # as we already checked it for the whole dataframe before. |
1323 | | - assert_series_equal( |
1324 | | - lcol, |
1325 | | - rcol, |
1326 | | - check_dtype=check_dtype, |
1327 | | - check_index_type=check_index_type, |
1328 | | - check_exact=check_exact, |
1329 | | - check_names=check_names, |
1330 | | - check_datetimelike_compat=check_datetimelike_compat, |
1331 | | - check_categorical=check_categorical, |
1332 | | - check_freq=check_freq, |
1333 | | - obj=f'{obj}.iloc[:, {i}] (column name="{col}")', |
1334 | | - rtol=rtol, |
1335 | | - atol=atol, |
1336 | | - check_index=False, |
1337 | | - check_flags=False, |
1338 | | - ) |
| 1334 | + with warnings.catch_warnings(): |
| 1335 | + warnings.filterwarnings( |
| 1336 | + "ignore", |
| 1337 | + message="the 'check_datetimelike_compat' keyword", |
| 1338 | + category=Pandas4Warning, |
| 1339 | + ) |
| 1340 | + assert_series_equal( |
| 1341 | + lcol, |
| 1342 | + rcol, |
| 1343 | + check_dtype=check_dtype, |
| 1344 | + check_index_type=check_index_type, |
| 1345 | + check_exact=check_exact, |
| 1346 | + check_names=check_names, |
| 1347 | + check_datetimelike_compat=check_datetimelike_compat, |
| 1348 | + check_categorical=check_categorical, |
| 1349 | + check_freq=check_freq, |
| 1350 | + obj=f'{obj}.iloc[:, {i}] (column name="{col}")', |
| 1351 | + rtol=rtol, |
| 1352 | + atol=atol, |
| 1353 | + check_index=False, |
| 1354 | + check_flags=False, |
| 1355 | + ) |
1339 | 1356 |
|
1340 | 1357 |
|
1341 | 1358 | def assert_equal(left, right, **kwargs) -> None: |
|
0 commit comments