Skip to content

Commit addefa0

Browse files
committed
BLD: rename / move some extensions
xref #12588 pandas.parser -> io/libparsers.pyx pandas.json -> pandas.io.json.libjson pandas.io.sas.saslib -> libsas pandas.msgpack -> pandas.io.msgpack pandas._testing -> pandas.util.libtesting pandas._sparse -> pandas.sparse.libsparse pandas._hash -> pandas.tools.libhash pandas.tslib -> pandas.libs.tslib pandas.index -> pandas.libs.index pandas.algos -> pandas.libs.algos pandas.lib -> pandas.libs.lib pandas.hashtable -> pandas.libs.hashtable pandas._window -> pandas.core.libwindow pandas._join -> pandas.libs.join move algos*.in, index*.in, hashtable*.in to libs pandas._period -> pandas.libs.period
1 parent cd67704 commit addefa0

File tree

193 files changed

+618
-504
lines changed

Some content is hidden

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

193 files changed

+618
-504
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tseries: pandas/lib.pyx pandas/tslib.pyx pandas/hashtable.pyx
1+
tseries: pandas/libs/lib.pyx pandas/libs/tslib.pyx pandas/libs/hashtable.pyx
22
python setup.py build_ext --inplace
33

44
.PHONY : develop build clean clean_pyc tseries doc

asv_bench/benchmarks/binary_ops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,4 @@ def setup(self):
107107
self.s = Series(date_range('20010101', periods=self.N, freq='T', tz='US/Eastern'))
108108
self.ts = self.s[self.halfway]
109109

110-
self.s2 = Series(date_range('20010101', periods=self.N, freq='s', tz='US/Eastern'))
110+
self.s2 = Series(date_range('20010101', periods=self.N, freq='s', tz='US/Eastern'))

asv_bench/benchmarks/pandas_vb_common.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,22 @@
88
import random
99
import numpy as np
1010
import threading
11+
from importlib import import_module
12+
1113
try:
1214
from pandas.compat import range
1315
except ImportError:
1416
pass
1517

1618
np.random.seed(1234)
17-
try:
18-
import pandas._tseries as lib
19-
except:
20-
import pandas.lib as lib
19+
20+
# try em until it works!
21+
for imp in ['pandas_tseries', 'pandas.lib', 'pandas.libs.lib']:
22+
try:
23+
lib = import_module(imp)
24+
break
25+
except:
26+
pass
2127

2228
try:
2329
Panel = Panel

asv_bench/benchmarks/panel_methods.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ def time_shift(self):
2121
self.panel.shift(1)
2222

2323
def time_shift_minor(self):
24-
self.panel.shift(1, axis='minor')
24+
self.panel.shift(1, axis='minor')

doc/source/whatsnew/v0.20.0.txt

+29
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,35 @@ New Behavior:
447447
In [11]: index.memory_usage(deep=True)
448448
Out[11]: 260
449449

450+
.. _whatsnew_0200.api_breaking.extensions:
451+
452+
Extension Modules Moved
453+
^^^^^^^^^^^^^^^^^^^^^^^
454+
455+
Some formerly public c/c++/cython extension modules have been moved and/or renamed. These are all removed from the public API.
456+
If indicated, a deprecation warning will be issued if you reference that module. (:issue:`12588`)
457+
458+
.. csv-table::
459+
:header: "Previous Location", "New Location", "Deprecated"
460+
:widths: 30, 30, 4
461+
462+
"pandas.json", "pandas.io.json.libjson", "X"
463+
"pandas.parser", "pandas.io.libparsers", "X"
464+
"pandas.lib", "pandas.libs.lib", "X"
465+
"pandas.tslib", "pandas.libs.tslib", "X"
466+
"pandas.io.sas.saslib", "pandas.io.sas.libsas", ""
467+
"pandas.msgpack", "pandas.io.msgpack", ""
468+
"pandas.index", "pandas.libs.index", ""
469+
"pandas.algos", "pandas.libs.algos", ""
470+
"pandas.hashtable", "pandas.libs.hashtable", ""
471+
"pandas._testing", "pandas.util.libtesting", ""
472+
"pandas._sparse", "pandas.sparse.libsparse", ""
473+
"pandas._hash", "pandas.tools.libhash", ""
474+
"pandas._window", "pandas.core.libwindow", ""
475+
"pandas._join", "pandas.libs.join", ""
476+
"pandas._period", "pandas.libs.period", ""
477+
478+
450479
.. _whatsnew_0200.api_breaking.groupby_describe:
451480

452481
Groupby Describe Formatting

pandas/__init__.py

+11-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
from pandas.compat.numpy import *
2424

2525
try:
26-
from pandas import hashtable, tslib, lib
26+
from pandas.libs import (hashtable as _hashtable,
27+
lib as _lib,
28+
tslib as _tslib)
2729
except ImportError as e: # pragma: no cover
2830
# hack but overkill to use re
2931
module = str(e).lstrip('cannot import name ')
@@ -53,11 +55,17 @@
5355
from pandas.tools.util import to_numeric
5456
from pandas.core.reshape import melt
5557
from pandas.util.print_versions import show_versions
56-
5758
from pandas.io.api import *
58-
5959
from pandas.util._tester import test
6060

61+
# extension module deprecations
62+
from pandas.util.depr_module import _DeprecatedModule
63+
64+
json = _DeprecatedModule(deprmod='pandas.json', deprmodto='pandas.io.json.libjson')
65+
parser = _DeprecatedModule(deprmod='pandas.parser', deprmodto='pandas.io.libparsers')
66+
lib = _DeprecatedModule(deprmod='pandas.lib', deprmodto='pandas.libs.lib')
67+
tslib = _DeprecatedModule(deprmod='pandas.tslib', deprmodto='pandas.libs.tslib')
68+
6169
# use the closest tagged version if possible
6270
from ._version import get_versions
6371
v = get_versions()

pandas/compat/pickle_compat.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@ def load_reduce(self):
6161
('pandas.core.base', 'FrozenList'): ('pandas.indexes.frozen', 'FrozenList'),
6262

6363
# 10890
64-
('pandas.core.series', 'TimeSeries'): ('pandas.core.series', 'Series')
64+
('pandas.core.series', 'TimeSeries'): ('pandas.core.series', 'Series'),
65+
66+
# 12588, extensions moving
67+
('pandas._sparse', 'BlockIndex'): ('pandas.sparse.libsparse', 'BlockIndex'),
68+
('pandas.tslib', 'Timestamp'): ('pandas.libs.tslib', 'Timestamp'),
69+
('pandas.tslib', '__nat_unpickle'): ('pandas.libs.tslib', '__nat_unpickle'),
70+
('pandas._period', 'Period'): ('pandas.libs.period', 'Period')
6571
}
6672

6773

pandas/computation/scope.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def _raw_hex_id(obj):
4646

4747

4848
_DEFAULT_GLOBALS = {
49-
'Timestamp': pd.lib.Timestamp,
49+
'Timestamp': pd.libs.lib.Timestamp,
5050
'datetime': datetime.datetime,
5151
'True': True,
5252
'False': False,

pandas/core/algorithms.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from warnings import warn
77
import numpy as np
88

9-
from pandas import compat, lib, tslib, _np_version_under1p8
9+
from pandas import compat, _np_version_under1p8
1010
from pandas.types.cast import _maybe_promote
1111
from pandas.types.generic import ABCSeries, ABCIndex
1212
from pandas.types.common import (is_unsigned_integer_dtype,
@@ -34,10 +34,9 @@
3434
from pandas.types.missing import isnull
3535

3636
import pandas.core.common as com
37-
import pandas.algos as algos
38-
import pandas.hashtable as htable
3937
from pandas.compat import string_types
40-
from pandas.tslib import iNaT
38+
from pandas.libs import algos, lib, hashtable as htable
39+
from pandas.libs.tslib import iNaT
4140

4241

4342
# --------------- #
@@ -1412,7 +1411,7 @@ def diff(arr, n, axis=0):
14121411
if needs_i8_conversion(arr):
14131412
dtype = np.float64
14141413
arr = arr.view('i8')
1415-
na = tslib.iNaT
1414+
na = iNaT
14161415
is_timedelta = True
14171416
elif issubclass(dtype.type, np.integer):
14181417
dtype = np.float64

pandas/core/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from pandas.core import common as com
1414
import pandas.core.nanops as nanops
15-
import pandas.lib as lib
15+
import pandas.libs.lib as lib
1616
from pandas.compat.numpy import function as nv
1717
from pandas.util.decorators import (Appender, cache_readonly,
1818
deprecate_kwarg, Substitution)

pandas/core/categorical.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
from warnings import warn
55
import types
66

7-
from pandas import compat, lib
7+
from pandas import compat
88
from pandas.compat import u, lzip
9-
import pandas.algos as _algos
9+
from pandas.libs import lib, algos as _algos
1010

1111
from pandas.types.generic import ABCSeries, ABCIndexClass, ABCCategoricalIndex
1212
from pandas.types.missing import isnull, notnull
@@ -1897,7 +1897,7 @@ def mode(self):
18971897
modes : `Categorical` (sorted)
18981898
"""
18991899

1900-
import pandas.hashtable as htable
1900+
import pandas.libs.hashtable as htable
19011901
good = self._codes != -1
19021902
values = sorted(htable.mode_int64(_ensure_int64(self._codes[good])))
19031903
result = self._constructor(values=values, categories=self.categories,

pandas/core/common.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from functools import partial
99

1010
import numpy as np
11-
import pandas.lib as lib
12-
import pandas.tslib as tslib
11+
from pandas.libs import lib, tslib
12+
1313
from pandas import compat
1414
from pandas.compat import long, zip, iteritems
1515
from pandas.core.config import get_option
@@ -476,7 +476,6 @@ def _where_compat(mask, arr1, arr2):
476476
new_vals = np.where(mask, arr1.view('i8'), arr2.view('i8'))
477477
return new_vals.view(_NS_DTYPE)
478478

479-
import pandas.tslib as tslib
480479
if arr1.dtype == _NS_DTYPE:
481480
arr1 = tslib.ints_to_pydatetime(arr1.view('i8'))
482481
if arr2.dtype == _NS_DTYPE:

pandas/core/frame.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@
9393
from pandas.formats.printing import pprint_thing
9494
import pandas.tools.plotting as gfx
9595

96-
import pandas.lib as lib
97-
import pandas.algos as _algos
96+
from pandas.libs import lib, algos as _algos
9897

9998
from pandas.core.config import get_option
10099

@@ -3162,7 +3161,7 @@ def duplicated(self, subset=None, keep='first'):
31623161
duplicated : Series
31633162
"""
31643163
from pandas.core.sorting import get_group_index
3165-
from pandas.hashtable import duplicated_int64, _SIZE_HINT_LIMIT
3164+
from pandas.libs.hashtable import duplicated_int64, _SIZE_HINT_LIMIT
31663165

31673166
def f(vals):
31683167
labels, shape = algos.factorize(vals,

pandas/core/generic.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
import gc
77

88
import numpy as np
9-
import pandas.lib as lib
10-
119
import pandas as pd
1210

13-
11+
from pandas.libs import tslib, lib
1412
from pandas.types.common import (_coerce_to_dtype,
1513
_ensure_int64,
1614
needs_i8_conversion,
@@ -6037,7 +6035,7 @@ def cum_func(self, axis=None, skipna=True, *args, **kwargs):
60376035
issubclass(y.dtype.type, (np.datetime64, np.timedelta64))):
60386036
result = accum_func(y, axis)
60396037
mask = isnull(self)
6040-
np.putmask(result, mask, pd.tslib.iNaT)
6038+
np.putmask(result, mask, tslib.iNaT)
60416039
elif skipna and not issubclass(y.dtype.type, (np.integer, np.bool_)):
60426040
mask = isnull(self)
60436041
np.putmask(y, mask, mask_a)

pandas/core/groupby.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@
5858
import pandas.core.algorithms as algos
5959
import pandas.core.common as com
6060
from pandas.core.config import option_context
61-
import pandas.lib as lib
62-
from pandas.lib import Timestamp
63-
import pandas.tslib as tslib
64-
import pandas.algos as _algos
61+
62+
from pandas.libs import lib, tslib, algos as _algos
63+
from pandas.libs.lib import Timestamp, count_level_2d
6564

6665
_doc_template = """
6766
@@ -3995,7 +3994,6 @@ def _apply_to_column_groupbys(self, func):
39953994
def count(self):
39963995
""" Compute count of group, excluding missing values """
39973996
from functools import partial
3998-
from pandas.lib import count_level_2d
39993997
from pandas.types.missing import _isnull_ndarraylike as isnull
40003998

40013999
data, _ = self._get_data_to_aggregate()

pandas/core/internals.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,17 @@
5353

5454
import pandas.core.missing as missing
5555
from pandas.sparse.array import _maybe_to_sparse, SparseArray
56-
import pandas.lib as lib
57-
import pandas.tslib as tslib
56+
from pandas.libs import lib, tslib
57+
from pandas.libs.tslib import Timedelta
58+
from pandas.libs.lib import BlockPlacement
59+
5860
import pandas.computation.expressions as expressions
5961
from pandas.util.decorators import cache_readonly
6062
from pandas.util.validators import validate_bool_kwarg
6163

62-
from pandas.tslib import Timedelta
6364
from pandas import compat, _np_version_under1p9
6465
from pandas.compat import range, map, zip, u
6566

66-
from pandas.lib import BlockPlacement
67-
6867

6968
class Block(PandasObject):
7069
"""

pandas/core/missing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import numpy as np
66
from distutils.version import LooseVersion
77

8-
import pandas.algos as algos
9-
import pandas.lib as lib
8+
from pandas.libs import algos, lib
9+
1010
from pandas.compat import range, string_types
1111
from pandas.types.common import (is_numeric_v_string_like,
1212
is_float_dtype, is_datetime64_dtype,

pandas/core/nanops.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
except ImportError: # pragma: no cover
1010
_USE_BOTTLENECK = False
1111

12-
from pandas import compat, lib, algos, tslib
12+
from pandas import compat
13+
from pandas.libs import tslib, algos, lib
1314
from pandas.types.common import (_get_dtype,
1415
is_float, is_scalar,
1516
is_integer, is_complex, is_float_dtype,

0 commit comments

Comments
 (0)