Skip to content

Commit

Permalink
CLN: make submodules of pandas.util private (pandas-dev#16223)
Browse files Browse the repository at this point in the history
* CLN: make submodules of pandas.util private

xref pandas-dev#13634

CLN: move pandas.util.*

validators, depr_module, decorators, print_versions

to _ leading

* CLN: move remaning extensions to _libs

* pandas.tools.hashing FutureWarning -> DeprecationWarning
  • Loading branch information
jreback authored and stangirala committed Jun 11, 2017
1 parent 3349ced commit 9dc4777
Show file tree
Hide file tree
Showing 94 changed files with 217 additions and 170 deletions.
2 changes: 1 addition & 1 deletion asv_bench/benchmarks/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pandas as pd
from pandas.util import testing as tm

for imp in ['pandas.util.hashing', 'pandas.tools.hashing']:
for imp in ['pandas.util', 'pandas.tools.hashing']:
try:
hashing = import_module(imp)
break
Expand Down
6 changes: 5 additions & 1 deletion asv_bench/benchmarks/attrs_caching.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from .pandas_vb_common import *
from pandas.util.decorators import cache_readonly

try:
from pandas.util import cache_readonly
except ImportError:
from pandas.util.decorators import cache_readonly


class DataFrameAttributes(object):
Expand Down
2 changes: 1 addition & 1 deletion doc/source/merging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import matplotlib.pyplot as plt
plt.close('all')
import pandas.util.doctools as doctools
import pandas.util._doctools as doctools
p = doctools.TablePlotter()
Expand Down
21 changes: 11 additions & 10 deletions doc/source/whatsnew/v0.20.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1230,19 +1230,19 @@ If indicated, a deprecation warning will be issued if you reference theses modul
"pandas.algos", "pandas._libs.algos", ""
"pandas.hashtable", "pandas._libs.hashtable", ""
"pandas.indexes", "pandas.core.indexes", ""
"pandas.json", "pandas.io.json.libjson", "X"
"pandas.parser", "pandas.io.libparsers", "X"
"pandas.json", "pandas._libs.json", "X"
"pandas.parser", "pandas._libs.parsers", "X"
"pandas.formats", "pandas.io.formats", ""
"pandas.sparse", "pandas.core.sparse", ""
"pandas.tools", "pandas.core.reshape", ""
"pandas.types", "pandas.core.dtypes", ""
"pandas.io.sas.saslib", "pandas.io.sas.libsas", ""
"pandas.io.sas.saslib", "pandas.io.sas._sas", ""
"pandas._join", "pandas._libs.join", ""
"pandas._hash", "pandas.util.libhashing", ""
"pandas._hash", "pandas._libs.hashing", ""
"pandas._period", "pandas._libs.period", ""
"pandas._sparse", "pandas.core.sparse.libsparse", ""
"pandas._testing", "pandas.util.libtesting", ""
"pandas._window", "pandas.core.libwindow", ""
"pandas._sparse", "pandas._libs.sparse", ""
"pandas._testing", "pandas._libs.testing", ""
"pandas._window", "pandas._libs.window", ""


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

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

.. _whatsnew_0200.privacy.errors:

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


.. _whatsnew_0200.privay.testing:
.. _whatsnew_0200.privacy.testing:

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


.. _whatsnew_0200.privay.plotting:
.. _whatsnew_0200.privacy.plotting:

``pandas.plotting``
^^^^^^^^^^^^^^^^^^^

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.


.. _whatsnew_0200.privacy.development:

Other Development Changes
Expand Down
6 changes: 3 additions & 3 deletions pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@
import pandas.tools.plotting
plot_params = pandas.plotting._style._Options(deprecated=True)
# do not import deprecate to top namespace
scatter_matrix = pandas.util.decorators.deprecate(
scatter_matrix = pandas.util._decorators.deprecate(
'pandas.scatter_matrix', pandas.plotting.scatter_matrix,
'pandas.plotting.scatter_matrix')

from pandas.util.print_versions import show_versions
from pandas.util._print_versions import show_versions
from pandas.io.api import *
from pandas.util._tester import test
import pandas.testing

# extension module deprecations
from pandas.util.depr_module import _DeprecatedModule
from pandas.util._depr_module import _DeprecatedModule

json = _DeprecatedModule(deprmod='pandas.json',
moved={'dumps': 'pandas.io.json.dumps',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions pandas/_libs/src/ujson/python/ujson.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ static struct PyModuleDef moduledef = {
NULL /* m_free */
};

#define PYMODINITFUNC PyMODINIT_FUNC PyInit_libjson(void)
#define PYMODINITFUNC PyMODINIT_FUNC PyInit_json(void)
#define PYMODULE_CREATE() PyModule_Create(&moduledef)
#define MODINITERROR return NULL

#else

#define PYMODINITFUNC PyMODINIT_FUNC initlibjson(void)
#define PYMODULE_CREATE() Py_InitModule("libjson", ujsonMethods)
#define PYMODINITFUNC PyMODINIT_FUNC initjson(void)
#define PYMODULE_CREATE() Py_InitModule("json", ujsonMethods)
#define MODINITERROR return

#endif
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions pandas/compat/numpy/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"""

from numpy import ndarray
from pandas.util.validators import (validate_args, validate_kwargs,
validate_args_and_kwargs)
from pandas.util._validators import (validate_args, validate_kwargs,
validate_args_and_kwargs)
from pandas.errors import UnsupportedFunctionCall
from pandas.core.dtypes.common import is_integer, is_bool
from pandas.compat import OrderedDict
Expand Down
2 changes: 1 addition & 1 deletion pandas/compat/pickle_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def load_reduce(self):

# 12588, extensions moving
('pandas._sparse', 'BlockIndex'):
('pandas.core.sparse.libsparse', 'BlockIndex'),
('pandas._libs.sparse', 'BlockIndex'),
('pandas.tslib', 'Timestamp'):
('pandas._libs.tslib', 'Timestamp'),
('pandas.tslib', '__nat_unpickle'):
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from pandas.core.resample import TimeGrouper

# see gh-14094.
from pandas.util.depr_module import _DeprecatedModule
from pandas.util._depr_module import _DeprecatedModule

_removals = ['day', 'bday', 'businessDay', 'cday', 'customBusinessDay',
'customBusinessMonthEnd', 'customBusinessMonthBegin',
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
from pandas.core.dtypes.missing import isnull
from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries, ABCIndexClass
from pandas.core.dtypes.common import is_object_dtype, is_list_like, is_scalar
from pandas.util.validators import validate_bool_kwarg
from pandas.util._validators import validate_bool_kwarg

from pandas.core import common as com
import pandas.core.nanops as nanops
import pandas._libs.lib as lib
from pandas.compat.numpy import function as nv
from pandas.util.decorators import (Appender, cache_readonly,
deprecate_kwarg, Substitution)
from pandas.util._decorators import (Appender, cache_readonly,
deprecate_kwarg, Substitution)
from pandas.core.common import AbstractMethodError

_shared_docs = dict()
Expand Down
8 changes: 4 additions & 4 deletions pandas/core/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
import pandas.core.common as com
from pandas.core.missing import interpolate_2d
from pandas.compat.numpy import function as nv
from pandas.util.decorators import (Appender, cache_readonly,
deprecate_kwarg, Substitution)
from pandas.util._decorators import (Appender, cache_readonly,
deprecate_kwarg, Substitution)

from pandas.util.terminal import get_terminal_size
from pandas.util.validators import validate_bool_kwarg
from pandas.io.formats.terminal import get_terminal_size
from pandas.util._validators import validate_bool_kwarg
from pandas.core.config import get_option


Expand Down
2 changes: 1 addition & 1 deletion pandas/core/computation/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pandas.core.computation.scope import _ensure_scope
from pandas.compat import string_types
from pandas.core.computation.engines import _engines
from pandas.util.validators import validate_bool_kwarg
from pandas.util._validators import validate_bool_kwarg


def _check_engine(engine):
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
OrderedDict, raise_with_traceback)
from pandas import compat
from pandas.compat.numpy import function as nv
from pandas.util.decorators import Appender, Substitution
from pandas.util.validators import validate_bool_kwarg
from pandas.util._decorators import Appender, Substitution
from pandas.util._validators import validate_bool_kwarg

from pandas.core.indexes.period import PeriodIndex
from pandas.core.indexes.datetimes import DatetimeIndex
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
from pandas.compat import (map, zip, lzip, lrange, string_types,
isidentifier, set_function_name)
import pandas.core.nanops as nanops
from pandas.util.decorators import Appender, Substitution, deprecate_kwarg
from pandas.util.validators import validate_bool_kwarg
from pandas.util._decorators import Appender, Substitution, deprecate_kwarg
from pandas.util._validators import validate_bool_kwarg
from pandas.core import config

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

def to_xarray(self):
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@
from pandas.core.sorting import (get_group_index_sorter, get_group_index,
compress_group_index, get_flattened_iterator,
decons_obs_group_ids, get_indexer_dict)
from pandas.util.decorators import (cache_readonly, Substitution,
Appender, make_signature)
from pandas.util._decorators import (cache_readonly, Substitution,
Appender, make_signature)
from pandas.io.formats.printing import pprint_thing
from pandas.util.validators import validate_kwargs
from pandas.util._validators import validate_kwargs

import pandas.core.algorithms as algorithms
import pandas.core.common as com
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@

from pandas.core.base import PandasObject, IndexOpsMixin
import pandas.core.base as base
from pandas.util.decorators import (Appender, Substitution, cache_readonly,
deprecate, deprecate_kwarg)
from pandas.util._decorators import (Appender, Substitution, cache_readonly,
deprecate, deprecate_kwarg)
from pandas.core.indexes.frozen import FrozenList
import pandas.core.common as com
import pandas.core.dtypes.concat as _concat
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from pandas.core.algorithms import take_1d


from pandas.util.decorators import Appender, cache_readonly
from pandas.util._decorators import Appender, cache_readonly
from pandas.core.config import get_option
from pandas.core.indexes.base import Index, _index_shared_docs
import pandas.core.base as base
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from pandas._libs.period import Period

from pandas.core.indexes.base import Index, _index_shared_docs
from pandas.util.decorators import Appender, cache_readonly
from pandas.util._decorators import Appender, cache_readonly
import pandas.core.dtypes.concat as _concat
import pandas.tseries.frequencies as frequencies

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
from pandas.core.tools.datetimes import (
parse_time_string, normalize_date, to_time)
from pandas.core.tools.timedeltas import to_timedelta
from pandas.util.decorators import (Appender, cache_readonly,
deprecate_kwarg, Substitution)
from pandas.util._decorators import (Appender, cache_readonly,
deprecate_kwarg, Substitution)
import pandas.core.common as com
import pandas.tseries.offsets as offsets
import pandas.core.tools.datetimes as tools
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from pandas.core.indexes.multi import MultiIndex
from pandas.compat.numpy import function as nv
from pandas.core import common as com
from pandas.util.decorators import cache_readonly, Appender
from pandas.util._decorators import cache_readonly, Appender
from pandas.core.config import get_option

import pandas.core.indexes.base as ibase
Expand Down
8 changes: 4 additions & 4 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
is_null_slice)

import pandas.core.base as base
from pandas.util.decorators import (Appender, cache_readonly,
deprecate, deprecate_kwarg)
from pandas.util._decorators import (Appender, cache_readonly,
deprecate, deprecate_kwarg)
import pandas.core.common as com
import pandas.core.missing as missing
import pandas.core.algorithms as algos
Expand Down Expand Up @@ -718,7 +718,7 @@ def _inferred_type_levels(self):
@cache_readonly
def _hashed_values(self):
""" return a uint64 ndarray of my hashed values """
from pandas.util.hashing import hash_tuples
from pandas.core.util.hashing import hash_tuples
return hash_tuples(self)

def _hashed_indexing_key(self, key):
Expand All @@ -740,7 +740,7 @@ def _hashed_indexing_key(self, key):
we need to stringify if we have mixed levels
"""
from pandas.util.hashing import hash_tuples
from pandas.core.util.hashing import hash_tuples

if not isinstance(key, tuple):
return hash_tuples(key)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pandas.core import algorithms
from pandas.core.indexes.base import (
Index, InvalidIndexError, _index_shared_docs)
from pandas.util.decorators import Appender, cache_readonly
from pandas.util._decorators import Appender, cache_readonly
import pandas.core.indexes.base as ibase


Expand Down
4 changes: 2 additions & 2 deletions pandas/core/indexes/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
from pandas.core.indexes.base import _index_shared_docs, _ensure_index

from pandas import compat
from pandas.util.decorators import (Appender, Substitution, cache_readonly,
deprecate_kwarg)
from pandas.util._decorators import (Appender, Substitution, cache_readonly,
deprecate_kwarg)
from pandas.compat import zip, u

import pandas.core.indexes.base as ibase
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/range.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pandas.compat import lrange, range
from pandas.compat.numpy import function as nv
from pandas.core.indexes.base import Index, _index_shared_docs
from pandas.util.decorators import Appender, cache_readonly
from pandas.util._decorators import Appender, cache_readonly
import pandas.core.indexes.base as ibase

from pandas.core.indexes.numeric import Int64Index
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from pandas.core.indexes.base import _index_shared_docs
import pandas.core.common as com
import pandas.core.dtypes.concat as _concat
from pandas.util.decorators import Appender, Substitution, deprecate_kwarg
from pandas.util._decorators import Appender, Substitution, deprecate_kwarg
from pandas.core.indexes.datetimelike import TimelikeOps, DatetimeIndexOpsMixin
from pandas.core.tools.timedeltas import (
to_timedelta, _coerce_scalar_to_timedelta_type)
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
from pandas._libs.lib import BlockPlacement

import pandas.core.computation.expressions as expressions
from pandas.util.decorators import cache_readonly
from pandas.util.validators import validate_bool_kwarg
from pandas.util._decorators import cache_readonly
from pandas.util._validators import validate_bool_kwarg

from pandas import compat, _np_version_under1p9
from pandas.compat import range, map, zip, u
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
tslib as libts, algos as libalgos, iNaT)

from pandas import compat
from pandas.util.decorators import Appender
from pandas.util._decorators import Appender
import pandas.core.computation.expressions as expressions

from pandas.compat import bind_method
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from pandas.core.ops import _op_descriptions
from pandas.core.series import Series
from pandas.core.reshape.util import cartesian_product
from pandas.util.decorators import (deprecate, Appender)
from pandas.util._decorators import (deprecate, Appender)

_shared_doc_kwargs = dict(
axes='items, major_axis, minor_axis',
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from pandas._libs.lib import Timestamp
from pandas._libs.period import IncompatibleFrequency

from pandas.util.decorators import Appender
from pandas.util._decorators import Appender
from pandas.core.generic import _shared_docs
_shared_docs_kwargs = dict()

Expand Down
Loading

0 comments on commit 9dc4777

Please sign in to comment.