Skip to content

Commit 5d1d491

Browse files
committed
BLD: rename / move some extensions
xref pandas-dev#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 5d1d491

File tree

241 files changed

+876
-764
lines changed

Some content is hidden

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

241 files changed

+876
-764
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

+5-5
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 libalgos
1010

1111
from pandas.types.generic import ABCSeries, ABCIndexClass, ABCCategoricalIndex
1212
from pandas.types.missing import isnull, notnull
@@ -1817,8 +1817,8 @@ def _reverse_indexer(self):
18171817
18181818
"""
18191819
categories = self.categories
1820-
r, counts = _algos.groupsort_indexer(self.codes.astype('int64'),
1821-
categories.size)
1820+
r, counts = libalgos.groupsort_indexer(self.codes.astype('int64'),
1821+
categories.size)
18221822
counts = counts.cumsum()
18231823
result = [r[counts[indexer]:counts[indexer + 1]]
18241824
for indexer in range(len(counts) - 1)]
@@ -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

+15-17
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
from pandas.core.series import Series
7272
from pandas.core.categorical import Categorical
7373
import pandas.computation.expressions as expressions
74-
import pandas.core.algorithms as algos
74+
import pandas.core.algorithms as algorithms
7575
from pandas.computation.eval import eval as _eval
7676
from pandas.compat import (range, map, zip, lrange, lmap, lzip, StringIO, u,
7777
OrderedDict, raise_with_traceback)
@@ -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 libalgos
9897

9998
from pandas.core.config import get_option
10099

@@ -2776,8 +2775,8 @@ def _reindex_multi(self, axes, copy, fill_value):
27762775

27772776
if row_indexer is not None and col_indexer is not None:
27782777
indexer = row_indexer, col_indexer
2779-
new_values = algos.take_2d_multi(self.values, indexer,
2780-
fill_value=fill_value)
2778+
new_values = algorithms.take_2d_multi(self.values, indexer,
2779+
fill_value=fill_value)
27812780
return self._constructor(new_values, index=new_index,
27822781
columns=new_columns)
27832782
else:
@@ -3162,12 +3161,11 @@ 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):
3168-
labels, shape = algos.factorize(vals,
3169-
size_hint=min(len(self),
3170-
_SIZE_HINT_LIMIT))
3167+
labels, shape = algorithms.factorize(
3168+
vals, size_hint=min(len(self), _SIZE_HINT_LIMIT))
31713169
return labels.astype('i8', copy=False), len(shape)
31723170

31733171
if subset is None:
@@ -3419,7 +3417,7 @@ def nlargest(self, n, columns, keep='first'):
34193417
1 10 b 2
34203418
2 8 d NaN
34213419
"""
3422-
return algos.select_n_frame(self, columns, n, 'nlargest', keep)
3420+
return algorithms.select_n_frame(self, columns, n, 'nlargest', keep)
34233421

34243422
def nsmallest(self, n, columns, keep='first'):
34253423
"""Get the rows of a DataFrame sorted by the `n` smallest
@@ -3453,7 +3451,7 @@ def nsmallest(self, n, columns, keep='first'):
34533451
0 1 a 1
34543452
2 8 d NaN
34553453
"""
3456-
return algos.select_n_frame(self, columns, n, 'nsmallest', keep)
3454+
return algorithms.select_n_frame(self, columns, n, 'nsmallest', keep)
34573455

34583456
def swaplevel(self, i=-2, j=-1, axis=0):
34593457
"""
@@ -4721,10 +4719,10 @@ def corr(self, method='pearson', min_periods=1):
47214719
mat = numeric_df.values
47224720

47234721
if method == 'pearson':
4724-
correl = _algos.nancorr(_ensure_float64(mat), minp=min_periods)
4722+
correl = libalgos.nancorr(_ensure_float64(mat), minp=min_periods)
47254723
elif method == 'spearman':
4726-
correl = _algos.nancorr_spearman(_ensure_float64(mat),
4727-
minp=min_periods)
4724+
correl = libalgos.nancorr_spearman(_ensure_float64(mat),
4725+
minp=min_periods)
47284726
else:
47294727
if min_periods is None:
47304728
min_periods = 1
@@ -4784,8 +4782,8 @@ def cov(self, min_periods=None):
47844782
baseCov = np.cov(mat.T)
47854783
baseCov = baseCov.reshape((len(cols), len(cols)))
47864784
else:
4787-
baseCov = _algos.nancorr(_ensure_float64(mat), cov=True,
4788-
minp=min_periods)
4785+
baseCov = libalgos.nancorr(_ensure_float64(mat), cov=True,
4786+
minp=min_periods)
47894787

47904788
return self._constructor(baseCov, index=idx, columns=cols)
47914789

@@ -5651,7 +5649,7 @@ def _list_of_series_to_arrays(data, columns, coerce_float=False, dtype=None):
56515649
indexer = indexer_cache[id(index)] = index.get_indexer(columns)
56525650

56535651
values = _values_from_object(s)
5654-
aligned_values.append(algos.take_1d(values, indexer))
5652+
aligned_values.append(algorithms.take_1d(values, indexer))
56555653

56565654
values = np.vstack(aligned_values)
56575655

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)

0 commit comments

Comments
 (0)