Skip to content

Commit 00a7751

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 0b07b07 commit 00a7751

File tree

241 files changed

+877
-765
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

+877
-765
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
@@ -448,6 +448,35 @@ New Behavior:
448448
In [11]: index.memory_usage(deep=True)
449449
Out[11]: 260
450450

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

453482
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 ')
@@ -52,11 +54,17 @@
5254
from pandas.tools.util import to_numeric
5355
from pandas.core.reshape import melt
5456
from pandas.util.print_versions import show_versions
55-
5657
from pandas.io.api import *
57-
5858
from pandas.util._tester import test
5959

60+
# extension module deprecations
61+
from pandas.util.depr_module import _DeprecatedModule
62+
63+
json = _DeprecatedModule(deprmod='pandas.json', deprmodto='pandas.io.json.libjson')
64+
parser = _DeprecatedModule(deprmod='pandas.parser', deprmodto='pandas.io.libparsers')
65+
lib = _DeprecatedModule(deprmod='pandas.lib', deprmodto='pandas.libs.lib')
66+
tslib = _DeprecatedModule(deprmod='pandas.tslib', deprmodto='pandas.libs.tslib')
67+
6068
# use the closest tagged version if possible
6169
from ._version import get_versions
6270
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

@@ -2806,8 +2805,8 @@ def _reindex_multi(self, axes, copy, fill_value):
28062805

28072806
if row_indexer is not None and col_indexer is not None:
28082807
indexer = row_indexer, col_indexer
2809-
new_values = algos.take_2d_multi(self.values, indexer,
2810-
fill_value=fill_value)
2808+
new_values = algorithms.take_2d_multi(self.values, indexer,
2809+
fill_value=fill_value)
28112810
return self._constructor(new_values, index=new_index,
28122811
columns=new_columns)
28132812
else:
@@ -3192,12 +3191,11 @@ def duplicated(self, subset=None, keep='first'):
31923191
duplicated : Series
31933192
"""
31943193
from pandas.core.sorting import get_group_index
3195-
from pandas.hashtable import duplicated_int64, _SIZE_HINT_LIMIT
3194+
from pandas.libs.hashtable import duplicated_int64, _SIZE_HINT_LIMIT
31963195

31973196
def f(vals):
3198-
labels, shape = algos.factorize(vals,
3199-
size_hint=min(len(self),
3200-
_SIZE_HINT_LIMIT))
3197+
labels, shape = algorithms.factorize(
3198+
vals, size_hint=min(len(self), _SIZE_HINT_LIMIT))
32013199
return labels.astype('i8', copy=False), len(shape)
32023200

32033201
if subset is None:
@@ -3449,7 +3447,7 @@ def nlargest(self, n, columns, keep='first'):
34493447
1 10 b 2
34503448
2 8 d NaN
34513449
"""
3452-
return algos.select_n_frame(self, columns, n, 'nlargest', keep)
3450+
return algorithms.select_n_frame(self, columns, n, 'nlargest', keep)
34533451

34543452
def nsmallest(self, n, columns, keep='first'):
34553453
"""Get the rows of a DataFrame sorted by the `n` smallest
@@ -3483,7 +3481,7 @@ def nsmallest(self, n, columns, keep='first'):
34833481
0 1 a 1
34843482
2 8 d NaN
34853483
"""
3486-
return algos.select_n_frame(self, columns, n, 'nsmallest', keep)
3484+
return algorithms.select_n_frame(self, columns, n, 'nsmallest', keep)
34873485

34883486
def swaplevel(self, i=-2, j=-1, axis=0):
34893487
"""
@@ -4751,10 +4749,10 @@ def corr(self, method='pearson', min_periods=1):
47514749
mat = numeric_df.values
47524750

47534751
if method == 'pearson':
4754-
correl = _algos.nancorr(_ensure_float64(mat), minp=min_periods)
4752+
correl = libalgos.nancorr(_ensure_float64(mat), minp=min_periods)
47554753
elif method == 'spearman':
4756-
correl = _algos.nancorr_spearman(_ensure_float64(mat),
4757-
minp=min_periods)
4754+
correl = libalgos.nancorr_spearman(_ensure_float64(mat),
4755+
minp=min_periods)
47584756
else:
47594757
if min_periods is None:
47604758
min_periods = 1
@@ -4814,8 +4812,8 @@ def cov(self, min_periods=None):
48144812
baseCov = np.cov(mat.T)
48154813
baseCov = baseCov.reshape((len(cols), len(cols)))
48164814
else:
4817-
baseCov = _algos.nancorr(_ensure_float64(mat), cov=True,
4818-
minp=min_periods)
4815+
baseCov = libalgos.nancorr(_ensure_float64(mat), cov=True,
4816+
minp=min_periods)
48194817

48204818
return self._constructor(baseCov, index=idx, columns=cols)
48214819

@@ -5681,7 +5679,7 @@ def _list_of_series_to_arrays(data, columns, coerce_float=False, dtype=None):
56815679
indexer = indexer_cache[id(index)] = index.get_indexer(columns)
56825680

56835681
values = _values_from_object(s)
5684-
aligned_values.append(algos.take_1d(values, indexer))
5682+
aligned_values.append(algorithms.take_1d(values, indexer))
56855683

56865684
values = np.vstack(aligned_values)
56875685

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)