Skip to content

Commit bec46a7

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 09360d8 commit bec46a7

File tree

243 files changed

+884
-771
lines changed

Some content is hidden

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

243 files changed

+884
-771
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 10 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,35 @@ New Behavior:
484484
In [11]: index.memory_usage(deep=True)
485485
Out[11]: 260
486486

487+
.. _whatsnew_0200.api_breaking.extensions:
488+
489+
Extension Modules Moved
490+
^^^^^^^^^^^^^^^^^^^^^^^
491+
492+
Some formerly public c/c++/cython extension modules have been moved and/or renamed. These are all removed from the public API.
493+
If indicated, a deprecation warning will be issued if you reference that module. (:issue:`12588`)
494+
495+
.. csv-table::
496+
:header: "Previous Location", "New Location", "Deprecated"
497+
:widths: 30, 30, 4
498+
499+
"pandas.lib", "pandas._libs.lib", "X"
500+
"pandas.tslib", "pandas._libs.tslib", "X"
501+
"pandas._join", "pandas._libs.join", ""
502+
"pandas._period", "pandas._libs.period", ""
503+
"pandas.msgpack", "pandas.io.msgpack", ""
504+
"pandas.index", "pandas._libs.index", ""
505+
"pandas.algos", "pandas._libs.algos", ""
506+
"pandas.hashtable", "pandas._libs.hashtable", ""
507+
"pandas.json", "pandas.io.json.libjson", "X"
508+
"pandas.parser", "pandas.io.libparsers", "X"
509+
"pandas.io.sas.saslib", "pandas.io.sas.libsas", ""
510+
"pandas._testing", "pandas.util.libtesting", ""
511+
"pandas._sparse", "pandas.sparse.libsparse", ""
512+
"pandas._hash", "pandas.tools.libhash", ""
513+
"pandas._window", "pandas.core.libwindow", ""
514+
515+
487516
.. _whatsnew_0200.api_breaking.groupby_describe:
488517

489518
Groupby Describe Formatting

pandas/__init__.py

Lines changed: 11 additions & 3 deletions
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/_libs/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# flake8: noqa
2+
3+
from .tslib import iNaT, NaT, Timestamp, Timedelta, OutOfBoundsDatetime
4+
5+
# TODO
6+
# period is directly dependent on tslib and imports python
7+
# modules, so exposing Period as an alias is currently not possible
8+
# from period import Period

pandas/algos.pyx renamed to pandas/_libs/algos.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ float64 = np.dtype(np.float64)
3737
cdef double NaN = <double> np.NaN
3838
cdef double nan = NaN
3939

40-
cdef extern from "src/headers/math.h":
40+
cdef extern from "../src/headers/math.h":
4141
double sqrt(double x) nogil
4242
double fabs(double) nogil
4343

@@ -46,7 +46,7 @@ from util cimport numeric, get_nat
4646

4747
cimport lib
4848
from lib cimport is_null_datetimelike
49-
from pandas import lib
49+
from pandas._libs import lib
5050

5151
cdef int64_t iNaT = get_nat()
5252

pandas/src/algos_common_helper.pxi.in renamed to pandas/_libs/algos_common_helper.pxi.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def arrmap_{{name}}(ndarray[{{c_type}}] index, object func):
433433

434434
cdef ndarray[object] result = np.empty(length, dtype=np.object_)
435435

436-
from pandas.lib import maybe_convert_objects
436+
from pandas._libs.lib import maybe_convert_objects
437437

438438
for i in range(length):
439439
result[i] = func(index[i])

0 commit comments

Comments
 (0)