Skip to content

Commit c55a739

Browse files
DEPR: pandas.util.testing (#30620)
1 parent f937843 commit c55a739

File tree

510 files changed

+746
-533
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

510 files changed

+746
-533
lines changed

asv_bench/benchmarks/categoricals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44

55
import pandas as pd
6-
import pandas.util.testing as tm
6+
import pandas._testing as tm
77

88
try:
99
from pandas.api.types import union_categoricals

asv_bench/benchmarks/ctors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22

33
from pandas import DatetimeIndex, Index, MultiIndex, Series, Timestamp
4-
import pandas.util.testing as tm
4+
import pandas._testing as tm
55

66

77
def no_change(arr):

asv_bench/benchmarks/frame_ctor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22

33
from pandas import DataFrame, MultiIndex, Series, Timestamp, date_range
4-
import pandas.util.testing as tm
4+
import pandas._testing as tm
55

66
try:
77
from pandas.tseries.offsets import Nano, Hour

asv_bench/benchmarks/frame_methods.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import numpy as np
55

66
from pandas import DataFrame, MultiIndex, NaT, Series, date_range, isnull, period_range
7-
import pandas.util.testing as tm
7+
import pandas._testing as tm
88

99

1010
class GetNumericData:

asv_bench/benchmarks/gil.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import numpy as np
22

33
from pandas import DataFrame, Series, date_range, factorize, read_csv
4+
import pandas._testing as tm
45
from pandas.core.algorithms import take_1d
5-
import pandas.util.testing as tm
66

77
try:
88
from pandas import (
@@ -24,7 +24,7 @@
2424
except ImportError:
2525
from pandas import algos
2626
try:
27-
from pandas.util.testing import test_parallel
27+
from pandas._testing import test_parallel
2828

2929
have_real_test_parallel = True
3030
except ImportError:

asv_bench/benchmarks/groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
date_range,
1414
period_range,
1515
)
16-
import pandas.util.testing as tm
16+
import pandas._testing as tm
1717

1818
method_blacklist = {
1919
"object": {

asv_bench/benchmarks/index_object.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Series,
1313
date_range,
1414
)
15-
import pandas.util.testing as tm
15+
import pandas._testing as tm
1616

1717

1818
class SetOperations:

asv_bench/benchmarks/indexing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
option_context,
1818
period_range,
1919
)
20-
import pandas.util.testing as tm
20+
import pandas._testing as tm
2121

2222

2323
class NumericSeriesIndexing:

asv_bench/benchmarks/inference.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22

33
from pandas import DataFrame, Series, to_numeric
4-
import pandas.util.testing as tm
4+
import pandas._testing as tm
55

66
from .pandas_vb_common import lib, numeric_dtypes
77

asv_bench/benchmarks/io/csv.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66

77
from pandas import Categorical, DataFrame, date_range, read_csv, to_datetime
8-
import pandas.util.testing as tm
8+
import pandas._testing as tm
99

1010
from ..pandas_vb_common import BaseIO
1111

asv_bench/benchmarks/io/excel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from odf.text import P
77

88
from pandas import DataFrame, ExcelWriter, date_range, read_excel
9-
import pandas.util.testing as tm
9+
import pandas._testing as tm
1010

1111

1212
def _generate_dataframe():

asv_bench/benchmarks/io/hdf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22

33
from pandas import DataFrame, HDFStore, date_range, read_hdf
4-
import pandas.util.testing as tm
4+
import pandas._testing as tm
55

66
from ..pandas_vb_common import BaseIO
77

asv_bench/benchmarks/io/json.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22

33
from pandas import DataFrame, concat, date_range, read_json, timedelta_range
4-
import pandas.util.testing as tm
4+
import pandas._testing as tm
55

66
from ..pandas_vb_common import BaseIO
77

asv_bench/benchmarks/io/pickle.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22

33
from pandas import DataFrame, date_range, read_pickle
4-
import pandas.util.testing as tm
4+
import pandas._testing as tm
55

66
from ..pandas_vb_common import BaseIO
77

asv_bench/benchmarks/io/sql.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from sqlalchemy import create_engine
55

66
from pandas import DataFrame, date_range, read_sql_query, read_sql_table
7-
import pandas.util.testing as tm
7+
import pandas._testing as tm
88

99

1010
class SQL:

asv_bench/benchmarks/io/stata.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22

33
from pandas import DataFrame, date_range, read_stata
4-
import pandas.util.testing as tm
4+
import pandas._testing as tm
55

66
from ..pandas_vb_common import BaseIO
77

asv_bench/benchmarks/join_merge.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44

55
from pandas import DataFrame, MultiIndex, Series, concat, date_range, merge, merge_asof
6-
import pandas.util.testing as tm
6+
import pandas._testing as tm
77

88
try:
99
from pandas import merge_ordered

asv_bench/benchmarks/multiindex_object.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44

55
from pandas import DataFrame, MultiIndex, RangeIndex, date_range
6-
import pandas.util.testing as tm
6+
import pandas._testing as tm
77

88

99
class GetLoc:

asv_bench/benchmarks/reindex.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22

33
from pandas import DataFrame, Index, MultiIndex, Series, date_range, period_range
4-
import pandas.util.testing as tm
4+
import pandas._testing as tm
55

66
from .pandas_vb_common import lib
77

asv_bench/benchmarks/series_methods.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44

55
from pandas import NaT, Series, date_range
6-
import pandas.util.testing as tm
6+
import pandas._testing as tm
77

88

99
class SeriesConstructor:

asv_bench/benchmarks/strings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44

55
from pandas import DataFrame, Series
6-
import pandas.util.testing as tm
6+
import pandas._testing as tm
77

88

99
class Methods:

ci/code_checks.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
139139
RET=$(($RET + $?)) ; echo $MSG "DONE"
140140

141141
# Checks for test suite
142-
# Check for imports from pandas.util.testing instead of `import pandas.util.testing as tm`
143-
invgrep -R --include="*.py*" -E "from pandas.util.testing import" pandas/tests
142+
# Check for imports from pandas._testing instead of `import pandas._testing as tm`
143+
invgrep -R --include="*.py*" -E "from pandas._testing import" pandas/tests
144144
RET=$(($RET + $?)) ; echo $MSG "DONE"
145145
invgrep -R --include="*.py*" -E "from pandas.util import testing as tm" pandas/tests
146146
RET=$(($RET + $?)) ; echo $MSG "DONE"

doc/source/development/contributing.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ inspiration. If your test requires working with files or
956956
network connectivity, there is more information on the `testing page
957957
<https://github.com/pandas-dev/pandas/wiki/Testing>`_ of the wiki.
958958

959-
The ``pandas.util.testing`` module has many special ``assert`` functions that
959+
The ``pandas._testing`` module has many special ``assert`` functions that
960960
make it easier to make statements about whether Series or DataFrame objects are
961961
equivalent. The easiest way to verify that your code is correct is to
962962
explicitly construct the result you expect, then compare the actual result to
@@ -1142,7 +1142,7 @@ If your change involves checking that a warning is actually emitted, use
11421142

11431143
.. code-block:: python
11441144
1145-
import pandas.util.testing as tm
1145+
import pandas._testing as tm
11461146
11471147
11481148
df = pd.DataFrame()

doc/source/reference/general_utility_functions.rst

+12
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Working with options
1818
set_option
1919
option_context
2020

21+
.. _api.general.testing:
22+
2123
Testing functions
2224
-----------------
2325
.. autosummary::
@@ -26,6 +28,16 @@ Testing functions
2628
testing.assert_frame_equal
2729
testing.assert_series_equal
2830
testing.assert_index_equal
31+
testing.assert_equal
32+
testing.assert_almost_equal
33+
testing.assert_categorical_equal
34+
testing.assert_datetime_array_equal
35+
testing.assert_extension_array_equal
36+
testing.assert_interval_array_equal
37+
testing.assert_numpy_array_equal
38+
testing.assert_period_array_equal
39+
testing.assert_sp_array_equal
40+
testing.assert_timedelta_array_equal
2941

3042
Exceptions and warnings
3143
-----------------------

doc/source/user_guide/io.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ rows will skip the intervening rows.
15191519

15201520
.. ipython:: python
15211521
1522-
from pandas.util.testing import makeCustomDataframe as mkdf
1522+
from pandas._testing import makeCustomDataframe as mkdf
15231523
df = mkdf(5, 3, r_idx_nlevels=2, c_idx_nlevels=4)
15241524
df.to_csv('mi.csv')
15251525
print(open('mi.csv').read())

doc/source/user_guide/reshaping.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Reshaping by pivoting DataFrame objects
1414
.. ipython:: python
1515
:suppress:
1616
17-
import pandas.util.testing as tm
17+
import pandas._testing as tm
1818
tm.N = 3
1919
2020
def unpivot(frame):
@@ -38,7 +38,7 @@ For the curious here is how the above ``DataFrame`` was created:
3838

3939
.. code-block:: python
4040
41-
import pandas.util.testing as tm
41+
import pandas._testing as tm
4242
4343
tm.N = 3
4444

doc/source/user_guide/scale.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Assuming you want or need the expressiveness and power of pandas, let's carry on
2626
.. ipython:: python
2727
:suppress:
2828
29-
from pandas.util.testing import _make_timeseries
29+
from pandas._testing import _make_timeseries
3030
3131
# Make a random in-memory dataset
3232
ts = _make_timeseries(freq="30S", seed=0)

doc/source/whatsnew/v0.12.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ I/O enhancements
236236

237237
.. ipython:: python
238238
239-
from pandas.util.testing import makeCustomDataframe as mkdf
239+
from pandas._testing import makeCustomDataframe as mkdf
240240
df = mkdf(5, 3, r_idx_nlevels=2, c_idx_nlevels=4)
241241
df.to_csv('mi.csv')
242242
print(open('mi.csv').read())

doc/source/whatsnew/v0.13.1.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Enhancements
224224

225225
.. code-block:: ipython
226226
227-
In [28]: import pandas.util.testing as tm
227+
In [28]: import pandas._testing as tm
228228
229229
In [29]: panel = tm.makePanel(5)
230230

doc/source/whatsnew/v0.18.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ Bug Fixes
12791279

12801280
- Removed ``millisecond`` property of ``DatetimeIndex``. This would always raise a ``ValueError`` (:issue:`12019`).
12811281
- Bug in ``Series`` constructor with read-only data (:issue:`11502`)
1282-
- Removed ``pandas.util.testing.choice()``. Should use ``np.random.choice()``, instead. (:issue:`12386`)
1282+
- Removed ``pandas._testing.choice()``. Should use ``np.random.choice()``, instead. (:issue:`12386`)
12831283
- Bug in ``.loc`` setitem indexer preventing the use of a TZ-aware DatetimeIndex (:issue:`12050`)
12841284
- Bug in ``.style`` indexes and MultiIndexes not appearing (:issue:`11655`)
12851285
- Bug in ``to_msgpack`` and ``from_msgpack`` which did not correctly serialize or deserialize ``NaT`` (:issue:`12307`).

doc/source/whatsnew/v0.20.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1360,7 +1360,7 @@ provides a :meth:`~Panel.to_xarray` method to automate this conversion (:issue:`
13601360

13611361
.. code-block:: ipython
13621362
1363-
In [133]: import pandas.util.testing as tm
1363+
In [133]: import pandas._testing as tm
13641364
13651365
In [134]: p = tm.makePanel()
13661366

doc/source/whatsnew/v0.21.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ Other API changes
927927
- :class:`pandas.HDFStore`'s string representation is now faster and less detailed. For the previous behavior, use ``pandas.HDFStore.info()``. (:issue:`16503`).
928928
- Compression defaults in HDF stores now follow pytables standards. Default is no compression and if ``complib`` is missing and ``complevel`` > 0 ``zlib`` is used (:issue:`15943`)
929929
- ``Index.get_indexer_non_unique()`` now returns a ndarray indexer rather than an ``Index``; this is consistent with ``Index.get_indexer()`` (:issue:`16819`)
930-
- Removed the ``@slow`` decorator from ``pandas.util.testing``, which caused issues for some downstream packages' test suites. Use ``@pytest.mark.slow`` instead, which achieves the same thing (:issue:`16850`)
930+
- Removed the ``@slow`` decorator from ``pandas._testing``, which caused issues for some downstream packages' test suites. Use ``@pytest.mark.slow`` instead, which achieves the same thing (:issue:`16850`)
931931
- Moved definition of ``MergeError`` to the ``pandas.errors`` module.
932932
- The signature of :func:`Series.set_axis` and :func:`DataFrame.set_axis` has been changed from ``set_axis(axis, labels)`` to ``set_axis(labels, axis=0)``, for consistency with the rest of the API. The old signature is deprecated and will show a ``FutureWarning`` (:issue:`14636`)
933933
- :func:`Series.argmin` and :func:`Series.argmax` will now raise a ``TypeError`` when used with ``object`` dtypes, instead of a ``ValueError`` (:issue:`13595`)

doc/source/whatsnew/v0.23.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ provides a :meth:`~Panel.to_xarray` method to automate this conversion (:issue:`
648648

649649
.. code-block:: ipython
650650
651-
In [75]: import pandas.util.testing as tm
651+
In [75]: import pandas._testing as tm
652652
653653
In [76]: p = tm.makePanel()
654654

doc/source/whatsnew/v1.0.0.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ Deprecations
577577
it is recommended to use ``json_normalize`` as :func:`pandas.json_normalize` instead (:issue:`27586`).
578578
- :meth:`DataFrame.to_stata`, :meth:`DataFrame.to_feather`, and :meth:`DataFrame.to_parquet` argument "fname" is deprecated, use "path" instead (:issue:`23574`)
579579
- The deprecated internal attributes ``_start``, ``_stop`` and ``_step`` of :class:`RangeIndex` now raise a ``FutureWarning`` instead of a ``DeprecationWarning`` (:issue:`26581`)
580+
- The ``pandas.util.testing`` module has been deprecated. Use the public API in ``pandas.testing`` documented at :ref:`api.general.testing` (:issue:`16232`).
580581

581582
**Selecting Columns from a Grouped DataFrame**
582583

@@ -703,7 +704,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
703704
- Ability to read pickles containing :class:`Categorical` instances created with pre-0.16 version of pandas has been removed (:issue:`27538`)
704705
- Removed :func:`pandas.tseries.plotting.tsplot` (:issue:`18627`)
705706
- Removed the previously deprecated keywords "reduce" and "broadcast" from :meth:`DataFrame.apply` (:issue:`18577`)
706-
- Removed the previously deprecated ``assert_raises_regex`` function in ``pandas.util.testing`` (:issue:`29174`)
707+
- Removed the previously deprecated ``assert_raises_regex`` function in ``pandas._testing`` (:issue:`29174`)
707708
- Removed the previously deprecated ``FrozenNDArray`` class in ``pandas.core.indexes.frozen`` (:issue:`29335`)
708709
- Removed the previously deprecated keyword "nthreads" from :func:`read_feather`, use "use_threads" instead (:issue:`23053`)
709710
- Removed :meth:`Index.is_lexsorted_for_tuple` (:issue:`29305`)

0 commit comments

Comments
 (0)