Skip to content

Commit e99f56e

Browse files
authored
CLN: make submodules of pandas.util private (#16223)
* CLN: make submodules of pandas.util private xref #13634 CLN: move pandas.util.* validators, depr_module, decorators, print_versions to _ leading * CLN: move remaning extensions to _libs * pandas.tools.hashing FutureWarning -> DeprecationWarning
1 parent 1f5ecc9 commit e99f56e

Some content is hidden

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

94 files changed

+217
-170
lines changed

asv_bench/benchmarks/algorithms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pandas as pd
66
from pandas.util import testing as tm
77

8-
for imp in ['pandas.util.hashing', 'pandas.tools.hashing']:
8+
for imp in ['pandas.util', 'pandas.tools.hashing']:
99
try:
1010
hashing = import_module(imp)
1111
break

asv_bench/benchmarks/attrs_caching.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
from .pandas_vb_common import *
2-
from pandas.util.decorators import cache_readonly
2+
3+
try:
4+
from pandas.util import cache_readonly
5+
except ImportError:
6+
from pandas.util.decorators import cache_readonly
37

48

59
class DataFrameAttributes(object):

doc/source/merging.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1414
import matplotlib.pyplot as plt
1515
plt.close('all')
16-
import pandas.util.doctools as doctools
16+
import pandas.util._doctools as doctools
1717
p = doctools.TablePlotter()
1818
1919

doc/source/whatsnew/v0.20.0.txt

+11-10
Original file line numberDiff line numberDiff line change
@@ -1230,19 +1230,19 @@ If indicated, a deprecation warning will be issued if you reference theses modul
12301230
"pandas.algos", "pandas._libs.algos", ""
12311231
"pandas.hashtable", "pandas._libs.hashtable", ""
12321232
"pandas.indexes", "pandas.core.indexes", ""
1233-
"pandas.json", "pandas.io.json.libjson", "X"
1234-
"pandas.parser", "pandas.io.libparsers", "X"
1233+
"pandas.json", "pandas._libs.json", "X"
1234+
"pandas.parser", "pandas._libs.parsers", "X"
12351235
"pandas.formats", "pandas.io.formats", ""
12361236
"pandas.sparse", "pandas.core.sparse", ""
12371237
"pandas.tools", "pandas.core.reshape", ""
12381238
"pandas.types", "pandas.core.dtypes", ""
1239-
"pandas.io.sas.saslib", "pandas.io.sas.libsas", ""
1239+
"pandas.io.sas.saslib", "pandas.io.sas._sas", ""
12401240
"pandas._join", "pandas._libs.join", ""
1241-
"pandas._hash", "pandas.util.libhashing", ""
1241+
"pandas._hash", "pandas._libs.hashing", ""
12421242
"pandas._period", "pandas._libs.period", ""
1243-
"pandas._sparse", "pandas.core.sparse.libsparse", ""
1244-
"pandas._testing", "pandas.util.libtesting", ""
1245-
"pandas._window", "pandas.core.libwindow", ""
1243+
"pandas._sparse", "pandas._libs.sparse", ""
1244+
"pandas._testing", "pandas._libs.testing", ""
1245+
"pandas._window", "pandas._libs.window", ""
12461246

12471247

12481248
Some new subpackages are created with public functionality that is not directly
@@ -1254,6 +1254,8 @@ these are now the public subpackages.
12541254

12551255
- The function :func:`~pandas.api.types.union_categoricals` is now importable from ``pandas.api.types``, formerly from ``pandas.types.concat`` (:issue:`15998`)
12561256
- The type import ``pandas.tslib.NaTType`` is deprecated and can be replaced by using ``type(pandas.NaT)`` (:issue:`16146`)
1257+
- The public functions in ``pandas.tools.hashing`` deprecated from that locations, but are now importable from ``pandas.util`` (:issue:`16223`)
1258+
- The modules in ``pandas.util``: ``decorators``, ``print_versions``, ``doctools``, `validators``, ``depr_module`` are now private (:issue:`16223`)
12571259

12581260
.. _whatsnew_0200.privacy.errors:
12591261

@@ -1278,7 +1280,7 @@ The following are now part of this API:
12781280
'UnsupportedFunctionCall']
12791281

12801282

1281-
.. _whatsnew_0200.privay.testing:
1283+
.. _whatsnew_0200.privacy.testing:
12821284

12831285
``pandas.testing``
12841286
^^^^^^^^^^^^^^^^^^
@@ -1292,14 +1294,13 @@ The following testing functions are now part of this API:
12921294
- :func:`testing.assert_index_equal`
12931295

12941296

1295-
.. _whatsnew_0200.privay.plotting:
1297+
.. _whatsnew_0200.privacy.plotting:
12961298

12971299
``pandas.plotting``
12981300
^^^^^^^^^^^^^^^^^^^
12991301

13001302
A new public ``pandas.plotting`` module has been added that holds plotting functionality that was previously in either ``pandas.tools.plotting`` or in the top-level namespace. See the :ref:`deprecations sections <whatsnew_0200.privacy.deprecate_plotting>` for more details.
13011303

1302-
13031304
.. _whatsnew_0200.privacy.development:
13041305

13051306
Other Development Changes

pandas/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@
5050
import pandas.tools.plotting
5151
plot_params = pandas.plotting._style._Options(deprecated=True)
5252
# do not import deprecate to top namespace
53-
scatter_matrix = pandas.util.decorators.deprecate(
53+
scatter_matrix = pandas.util._decorators.deprecate(
5454
'pandas.scatter_matrix', pandas.plotting.scatter_matrix,
5555
'pandas.plotting.scatter_matrix')
5656

57-
from pandas.util.print_versions import show_versions
57+
from pandas.util._print_versions import show_versions
5858
from pandas.io.api import *
5959
from pandas.util._tester import test
6060
import pandas.testing
6161

6262
# extension module deprecations
63-
from pandas.util.depr_module import _DeprecatedModule
63+
from pandas.util._depr_module import _DeprecatedModule
6464

6565
json = _DeprecatedModule(deprmod='pandas.json',
6666
moved={'dumps': 'pandas.io.json.dumps',
File renamed without changes.
File renamed without changes.
File renamed without changes.

pandas/_libs/src/ujson/python/ujson.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ static struct PyModuleDef moduledef = {
9090
NULL /* m_free */
9191
};
9292

93-
#define PYMODINITFUNC PyMODINIT_FUNC PyInit_libjson(void)
93+
#define PYMODINITFUNC PyMODINIT_FUNC PyInit_json(void)
9494
#define PYMODULE_CREATE() PyModule_Create(&moduledef)
9595
#define MODINITERROR return NULL
9696

9797
#else
9898

99-
#define PYMODINITFUNC PyMODINIT_FUNC initlibjson(void)
100-
#define PYMODULE_CREATE() Py_InitModule("libjson", ujsonMethods)
99+
#define PYMODINITFUNC PyMODINIT_FUNC initjson(void)
100+
#define PYMODULE_CREATE() Py_InitModule("json", ujsonMethods)
101101
#define MODINITERROR return
102102

103103
#endif
File renamed without changes.
File renamed without changes.

pandas/compat/numpy/function.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"""
2020

2121
from numpy import ndarray
22-
from pandas.util.validators import (validate_args, validate_kwargs,
23-
validate_args_and_kwargs)
22+
from pandas.util._validators import (validate_args, validate_kwargs,
23+
validate_args_and_kwargs)
2424
from pandas.errors import UnsupportedFunctionCall
2525
from pandas.core.dtypes.common import is_integer, is_bool
2626
from pandas.compat import OrderedDict

pandas/compat/pickle_compat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def load_reduce(self):
7171

7272
# 12588, extensions moving
7373
('pandas._sparse', 'BlockIndex'):
74-
('pandas.core.sparse.libsparse', 'BlockIndex'),
74+
('pandas._libs.sparse', 'BlockIndex'),
7575
('pandas.tslib', 'Timestamp'):
7676
('pandas._libs.tslib', 'Timestamp'),
7777
('pandas.tslib', '__nat_unpickle'):

pandas/core/api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from pandas.core.resample import TimeGrouper
3636

3737
# see gh-14094.
38-
from pandas.util.depr_module import _DeprecatedModule
38+
from pandas.util._depr_module import _DeprecatedModule
3939

4040
_removals = ['day', 'bday', 'businessDay', 'cday', 'customBusinessDay',
4141
'customBusinessMonthEnd', 'customBusinessMonthBegin',

pandas/core/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
from pandas.core.dtypes.missing import isnull
1010
from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries, ABCIndexClass
1111
from pandas.core.dtypes.common import is_object_dtype, is_list_like, is_scalar
12-
from pandas.util.validators import validate_bool_kwarg
12+
from pandas.util._validators import validate_bool_kwarg
1313

1414
from pandas.core import common as com
1515
import pandas.core.nanops as nanops
1616
import pandas._libs.lib as lib
1717
from pandas.compat.numpy import function as nv
18-
from pandas.util.decorators import (Appender, cache_readonly,
19-
deprecate_kwarg, Substitution)
18+
from pandas.util._decorators import (Appender, cache_readonly,
19+
deprecate_kwarg, Substitution)
2020
from pandas.core.common import AbstractMethodError
2121

2222
_shared_docs = dict()

pandas/core/categorical.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
import pandas.core.common as com
3535
from pandas.core.missing import interpolate_2d
3636
from pandas.compat.numpy import function as nv
37-
from pandas.util.decorators import (Appender, cache_readonly,
38-
deprecate_kwarg, Substitution)
37+
from pandas.util._decorators import (Appender, cache_readonly,
38+
deprecate_kwarg, Substitution)
3939

40-
from pandas.util.terminal import get_terminal_size
41-
from pandas.util.validators import validate_bool_kwarg
40+
from pandas.io.formats.terminal import get_terminal_size
41+
from pandas.util._validators import validate_bool_kwarg
4242
from pandas.core.config import get_option
4343

4444

pandas/core/computation/eval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pandas.core.computation.scope import _ensure_scope
1212
from pandas.compat import string_types
1313
from pandas.core.computation.engines import _engines
14-
from pandas.util.validators import validate_bool_kwarg
14+
from pandas.util._validators import validate_bool_kwarg
1515

1616

1717
def _check_engine(engine):

pandas/core/frame.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@
8080
OrderedDict, raise_with_traceback)
8181
from pandas import compat
8282
from pandas.compat.numpy import function as nv
83-
from pandas.util.decorators import Appender, Substitution
84-
from pandas.util.validators import validate_bool_kwarg
83+
from pandas.util._decorators import Appender, Substitution
84+
from pandas.util._validators import validate_bool_kwarg
8585

8686
from pandas.core.indexes.period import PeriodIndex
8787
from pandas.core.indexes.datetimes import DatetimeIndex

pandas/core/generic.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
from pandas.compat import (map, zip, lzip, lrange, string_types,
5252
isidentifier, set_function_name)
5353
import pandas.core.nanops as nanops
54-
from pandas.util.decorators import Appender, Substitution, deprecate_kwarg
55-
from pandas.util.validators import validate_bool_kwarg
54+
from pandas.util._decorators import Appender, Substitution, deprecate_kwarg
55+
from pandas.util._validators import validate_bool_kwarg
5656
from pandas.core import config
5757

5858
# goal is to be able to define the docs close to function, while still being
@@ -1382,7 +1382,7 @@ def to_clipboard(self, excel=None, sep=None, **kwargs):
13821382
- Windows: none
13831383
- OS X: none
13841384
"""
1385-
from pandas.io import clipboard
1385+
from pandas.io.clipboard import clipboard
13861386
clipboard.to_clipboard(self, excel=excel, sep=sep, **kwargs)
13871387

13881388
def to_xarray(self):

pandas/core/groupby.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
from pandas.core.sorting import (get_group_index_sorter, get_group_index,
5555
compress_group_index, get_flattened_iterator,
5656
decons_obs_group_ids, get_indexer_dict)
57-
from pandas.util.decorators import (cache_readonly, Substitution,
58-
Appender, make_signature)
57+
from pandas.util._decorators import (cache_readonly, Substitution,
58+
Appender, make_signature)
5959
from pandas.io.formats.printing import pprint_thing
60-
from pandas.util.validators import validate_kwargs
60+
from pandas.util._validators import validate_kwargs
6161

6262
import pandas.core.algorithms as algorithms
6363
import pandas.core.common as com

pandas/core/indexes/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141

4242
from pandas.core.base import PandasObject, IndexOpsMixin
4343
import pandas.core.base as base
44-
from pandas.util.decorators import (Appender, Substitution, cache_readonly,
45-
deprecate, deprecate_kwarg)
44+
from pandas.util._decorators import (Appender, Substitution, cache_readonly,
45+
deprecate, deprecate_kwarg)
4646
from pandas.core.indexes.frozen import FrozenList
4747
import pandas.core.common as com
4848
import pandas.core.dtypes.concat as _concat

pandas/core/indexes/category.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from pandas.core.algorithms import take_1d
1717

1818

19-
from pandas.util.decorators import Appender, cache_readonly
19+
from pandas.util._decorators import Appender, cache_readonly
2020
from pandas.core.config import get_option
2121
from pandas.core.indexes.base import Index, _index_shared_docs
2222
import pandas.core.base as base

pandas/core/indexes/datetimelike.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from pandas._libs.period import Period
2929

3030
from pandas.core.indexes.base import Index, _index_shared_docs
31-
from pandas.util.decorators import Appender, cache_readonly
31+
from pandas.util._decorators import Appender, cache_readonly
3232
import pandas.core.dtypes.concat as _concat
3333
import pandas.tseries.frequencies as frequencies
3434

pandas/core/indexes/datetimes.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
from pandas.core.tools.datetimes import (
4242
parse_time_string, normalize_date, to_time)
4343
from pandas.core.tools.timedeltas import to_timedelta
44-
from pandas.util.decorators import (Appender, cache_readonly,
45-
deprecate_kwarg, Substitution)
44+
from pandas.util._decorators import (Appender, cache_readonly,
45+
deprecate_kwarg, Substitution)
4646
import pandas.core.common as com
4747
import pandas.tseries.offsets as offsets
4848
import pandas.core.tools.datetimes as tools

pandas/core/indexes/interval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from pandas.core.indexes.multi import MultiIndex
2929
from pandas.compat.numpy import function as nv
3030
from pandas.core import common as com
31-
from pandas.util.decorators import cache_readonly, Appender
31+
from pandas.util._decorators import cache_readonly, Appender
3232
from pandas.core.config import get_option
3333

3434
import pandas.core.indexes.base as ibase

pandas/core/indexes/multi.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
is_null_slice)
2727

2828
import pandas.core.base as base
29-
from pandas.util.decorators import (Appender, cache_readonly,
30-
deprecate, deprecate_kwarg)
29+
from pandas.util._decorators import (Appender, cache_readonly,
30+
deprecate, deprecate_kwarg)
3131
import pandas.core.common as com
3232
import pandas.core.missing as missing
3333
import pandas.core.algorithms as algos
@@ -718,7 +718,7 @@ def _inferred_type_levels(self):
718718
@cache_readonly
719719
def _hashed_values(self):
720720
""" return a uint64 ndarray of my hashed values """
721-
from pandas.util.hashing import hash_tuples
721+
from pandas.core.util.hashing import hash_tuples
722722
return hash_tuples(self)
723723

724724
def _hashed_indexing_key(self, key):
@@ -740,7 +740,7 @@ def _hashed_indexing_key(self, key):
740740
we need to stringify if we have mixed levels
741741
742742
"""
743-
from pandas.util.hashing import hash_tuples
743+
from pandas.core.util.hashing import hash_tuples
744744

745745
if not isinstance(key, tuple):
746746
return hash_tuples(key)

pandas/core/indexes/numeric.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pandas.core import algorithms
1212
from pandas.core.indexes.base import (
1313
Index, InvalidIndexError, _index_shared_docs)
14-
from pandas.util.decorators import Appender, cache_readonly
14+
from pandas.util._decorators import Appender, cache_readonly
1515
import pandas.core.indexes.base as ibase
1616

1717

pandas/core/indexes/period.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
from pandas.core.indexes.base import _index_shared_docs, _ensure_index
4141

4242
from pandas import compat
43-
from pandas.util.decorators import (Appender, Substitution, cache_readonly,
44-
deprecate_kwarg)
43+
from pandas.util._decorators import (Appender, Substitution, cache_readonly,
44+
deprecate_kwarg)
4545
from pandas.compat import zip, u
4646

4747
import pandas.core.indexes.base as ibase

pandas/core/indexes/range.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pandas.compat import lrange, range
1414
from pandas.compat.numpy import function as nv
1515
from pandas.core.indexes.base import Index, _index_shared_docs
16-
from pandas.util.decorators import Appender, cache_readonly
16+
from pandas.util._decorators import Appender, cache_readonly
1717
import pandas.core.indexes.base as ibase
1818

1919
from pandas.core.indexes.numeric import Int64Index

pandas/core/indexes/timedeltas.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from pandas.core.indexes.base import _index_shared_docs
2828
import pandas.core.common as com
2929
import pandas.core.dtypes.concat as _concat
30-
from pandas.util.decorators import Appender, Substitution, deprecate_kwarg
30+
from pandas.util._decorators import Appender, Substitution, deprecate_kwarg
3131
from pandas.core.indexes.datetimelike import TimelikeOps, DatetimeIndexOpsMixin
3232
from pandas.core.tools.timedeltas import (
3333
to_timedelta, _coerce_scalar_to_timedelta_type)

pandas/core/internals.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
from pandas._libs.lib import BlockPlacement
6565

6666
import pandas.core.computation.expressions as expressions
67-
from pandas.util.decorators import cache_readonly
68-
from pandas.util.validators import validate_bool_kwarg
67+
from pandas.util._decorators import cache_readonly
68+
from pandas.util._validators import validate_bool_kwarg
6969

7070
from pandas import compat, _np_version_under1p9
7171
from pandas.compat import range, map, zip, u

pandas/core/ops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
tslib as libts, algos as libalgos, iNaT)
1616

1717
from pandas import compat
18-
from pandas.util.decorators import Appender
18+
from pandas.util._decorators import Appender
1919
import pandas.core.computation.expressions as expressions
2020

2121
from pandas.compat import bind_method

pandas/core/panel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from pandas.core.ops import _op_descriptions
3535
from pandas.core.series import Series
3636
from pandas.core.reshape.util import cartesian_product
37-
from pandas.util.decorators import (deprecate, Appender)
37+
from pandas.util._decorators import (deprecate, Appender)
3838

3939
_shared_doc_kwargs = dict(
4040
axes='items, major_axis, minor_axis',

pandas/core/resample.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from pandas._libs.lib import Timestamp
2626
from pandas._libs.period import IncompatibleFrequency
2727

28-
from pandas.util.decorators import Appender
28+
from pandas.util._decorators import Appender
2929
from pandas.core.generic import _shared_docs
3030
_shared_docs_kwargs = dict()
3131

0 commit comments

Comments
 (0)