Skip to content

BLD: rename some extensions #15532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion asv_bench/benchmarks/binary_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ def setup(self):
self.s = Series(date_range('20010101', periods=self.N, freq='T', tz='US/Eastern'))
self.ts = self.s[self.halfway]

self.s2 = Series(date_range('20010101', periods=self.N, freq='s', tz='US/Eastern'))
self.s2 = Series(date_range('20010101', periods=self.N, freq='s', tz='US/Eastern'))
2 changes: 1 addition & 1 deletion asv_bench/benchmarks/panel_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ def time_shift(self):
self.panel.shift(1)

def time_shift_minor(self):
self.panel.shift(1, axis='minor')
self.panel.shift(1, axis='minor')
21 changes: 21 additions & 0 deletions doc/source/whatsnew/v0.20.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,27 @@ New Behavior:
In [11]: index.memory_usage(deep=True)
Out[11]: 260

.. _whatsnew_0200.api_breaking.extensions:

Extension Modules Moved
^^^^^^^^^^^^^^^^^^^^^^^

Some formerly public c/c++/cython extension modules have been moved and/or renamed. These are all removed from the public API.
If indicated, a deprecation warning will be issued if you reference that module. (:issue:`12588`)

.. csv-table::
:header: "Previous Location", "New Location", "Deprecated"
:widths: 30, 30, 4

"pandas.json", "pandas.io.json.libjson", "X"
"pandas.parser", "pandas.io.libparsers", "X"
"pandas.io.sas.saslib", "pandas.io.sas.libsas", ""
"pandas.msgpack", "pandas.io.msgpack", ""
"pandas._testing", "pandas.util.libtesting", ""
"pandas._sparse", "pandas.sparse.libsparse", ""
"pandas._hash", "pandas.tools.libhash", ""


.. _whatsnew_0200.api_breaking.groupby_describe:

Groupby Describe Formatting
Expand Down
8 changes: 6 additions & 2 deletions pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@
from pandas.tools.util import to_numeric
from pandas.core.reshape import melt
from pandas.util.print_versions import show_versions

from pandas.io.api import *

from pandas.util._tester import test

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

json = _DeprecatedModule(deprmod='pandas.json', deprmodto='pandas.io.json.libjson')
parser = _DeprecatedModule(deprmod='pandas.parser', deprmodto='pandas.io.libparsers')

# use the closest tagged version if possible
from ._version import get_versions
v = get_versions()
Expand Down
5 changes: 4 additions & 1 deletion pandas/compat/pickle_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ def load_reduce(self):
('pandas.core.base', 'FrozenList'): ('pandas.indexes.frozen', 'FrozenList'),

# 10890
('pandas.core.series', 'TimeSeries'): ('pandas.core.series', 'Series')
('pandas.core.series', 'TimeSeries'): ('pandas.core.series', 'Series'),

# 12588, extensions moving
('pandas._sparse', 'BlockIndex'): ('pandas.sparse.libsparse', 'BlockIndex')
}


Expand Down
2 changes: 1 addition & 1 deletion pandas/core/reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from pandas.core.sparse import SparseDataFrame, SparseSeries
from pandas.sparse.array import SparseArray
from pandas._sparse import IntIndex
from pandas.sparse.libsparse import IntIndex

from pandas.core.categorical import Categorical, _factorize_from_iterable
from pandas.core.sorting import (get_group_index, compress_group_index,
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pandas.io.json import read_json
from pandas.io.html import read_html
from pandas.io.sql import read_sql, read_sql_table, read_sql_query
from pandas.io.sas.sasreader import read_sas
from pandas.io.sas import read_sas
from pandas.io.feather_format import read_feather
from pandas.io.stata import read_stata
from pandas.io.pickle import read_pickle, to_pickle
Expand Down
6 changes: 3 additions & 3 deletions pandas/io/excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
EmptyDataError, get_filepath_or_buffer,
_NA_VALUES)
from pandas.tseries.period import Period
from pandas import json
from pandas.io.json import libjson
from pandas.compat import (map, zip, reduce, range, lrange, u, add_metaclass,
string_types, OrderedDict)
from pandas.core import config
Expand Down Expand Up @@ -1434,7 +1434,7 @@ def write_cells(self, cells, sheet_name=None, startrow=0, startcol=0,
elif isinstance(cell.val, date):
num_format_str = self.date_format

stylekey = json.dumps(cell.style)
stylekey = libjson.dumps(cell.style)
if num_format_str:
stylekey += num_format_str

Expand Down Expand Up @@ -1562,7 +1562,7 @@ def write_cells(self, cells, sheet_name=None, startrow=0, startcol=0,
elif isinstance(cell.val, date):
num_format_str = self.date_format

stylekey = json.dumps(cell.style)
stylekey = libjson.dumps(cell.style)
if num_format_str:
stylekey += num_format_str

Expand Down
6 changes: 3 additions & 3 deletions pandas/io/json/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import numpy as np

import pandas.json as _json
from pandas.io.json import libjson
from pandas.tslib import iNaT
from pandas.compat import StringIO, long, u
from pandas import compat, isnull
Expand All @@ -13,8 +13,8 @@
from pandas.formats.printing import pprint_thing
from .normalize import _convert_to_line_delimits

loads = _json.loads
dumps = _json.dumps
loads = libjson.loads
dumps = libjson.dumps


# interface to/from
Expand Down
8 changes: 4 additions & 4 deletions pandas/msgpack/__init__.py → pandas/io/msgpack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from collections import namedtuple

from pandas.msgpack.exceptions import * # noqa
from pandas.msgpack._version import version # noqa
from pandas.io.msgpack.exceptions import * # noqa
from pandas.io.msgpack._version import version # noqa


class ExtType(namedtuple('ExtType', 'code data')):
Expand All @@ -19,8 +19,8 @@ def __new__(cls, code, data):

import os # noqa

from pandas.msgpack._packer import Packer # noqa
from pandas.msgpack._unpacker import unpack, unpackb, Unpacker # noqa
from pandas.io.msgpack._packer import Packer # noqa
from pandas.io.msgpack._unpacker import unpack, unpackb, Unpacker # noqa


def pack(o, stream, **kwargs):
Expand Down
6 changes: 3 additions & 3 deletions pandas/msgpack/_packer.pyx → pandas/io/msgpack/_packer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ from libc.stdlib cimport *
from libc.string cimport *
from libc.limits cimport *

from pandas.msgpack.exceptions import PackValueError
from pandas.msgpack import ExtType
from pandas.io.msgpack.exceptions import PackValueError
from pandas.io.msgpack import ExtType


cdef extern from "../src/msgpack/pack.h":
cdef extern from "../../src/msgpack/pack.h":
struct msgpack_packer:
char* buf
size_t length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ from libc.stdlib cimport *
from libc.string cimport *
from libc.limits cimport *

from pandas.msgpack.exceptions import (BufferFull, OutOfData,
UnpackValueError, ExtraData)
from pandas.msgpack import ExtType
from pandas.io.msgpack.exceptions import (BufferFull, OutOfData,
UnpackValueError, ExtraData)
from pandas.io.msgpack import ExtType


cdef extern from "../src/msgpack/unpack.h":
cdef extern from "../../src/msgpack/unpack.h":
ctypedef struct msgpack_user:
bint use_list
PyObject* object_hook
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pandas/io/packers.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
from pandas.core.internals import BlockManager, make_block, _safe_reshape
import pandas.core.internals as internals

from pandas.msgpack import Unpacker as _Unpacker, Packer as _Packer, ExtType
from pandas.io.msgpack import Unpacker as _Unpacker, Packer as _Packer, ExtType
from pandas.util._move import (
BadMove as _BadMove,
move_into_mutable_buffer as _move_into_mutable_buffer,
Expand Down
6 changes: 3 additions & 3 deletions pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from pandas.util.decorators import Appender

import pandas.lib as lib
import pandas.parser as _parser
import pandas.io.libparsers as libparsers


# BOM character (byte order mark)
Expand Down Expand Up @@ -1415,7 +1415,7 @@ def _convert_to_ndarrays(self, dct, na_values, na_fvalues, verbose=False,

if issubclass(cvals.dtype.type, np.integer) and self.compact_ints:
cvals = lib.downcast_int64(
cvals, _parser.na_values,
cvals, libparsers.na_values,
self.use_unsigned)

result[c] = cvals
Expand Down Expand Up @@ -1533,7 +1533,7 @@ def __init__(self, src, **kwds):
# #2442
kwds['allow_leading_cols'] = self.index_col is not False

self._reader = _parser.TextReader(src, **kwds)
self._reader = libparsers.TextReader(src, **kwds)

# XXX
self.usecols, self.usecols_dtype = _validate_usecols_arg(
Expand Down
5 changes: 3 additions & 2 deletions pandas/parser.pyx → pandas/io/parsers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ from cpython cimport (PyObject, PyBytes_FromString,
PyUnicode_Check, PyUnicode_AsUTF8String,
PyErr_Occurred, PyErr_Fetch)
from cpython.ref cimport PyObject, Py_XDECREF
from io.common import ParserError, DtypeWarning, EmptyDataError, ParserWarning
from pandas.io.common import (ParserError, DtypeWarning,
EmptyDataError, ParserWarning)

# Import CParserError as alias of ParserError for backwards compatibility.
# Ultimately, we want to remove this import. See gh-12665 and gh-14479.
from io.common import CParserError
from pandas.io.common import CParserError

cdef extern from "Python.h":
object PyUnicode_FromString(char *v)
Expand Down
1 change: 1 addition & 0 deletions pandas/io/sas/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .sasreader import read_sas # noqa
File renamed without changes.
2 changes: 1 addition & 1 deletion pandas/io/sas/sas7bdat.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import numpy as np
import struct
import pandas.io.sas.sas_constants as const
from pandas.io.sas.saslib import Parser
from pandas.io.sas.libsas import Parser


class _subheader_pointer(object):
Expand Down
7 changes: 7 additions & 0 deletions pandas/json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# flake8: noqa

import warnings
warnings.warn("The pandas.json module is deprecated and will be "
"removed in a future version. Please import from "
"the pandas.io.json instead", FutureWarning, stacklevel=2)
from pandas.io.json.libjson import dumps, loads
8 changes: 8 additions & 0 deletions pandas/parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# flake8: noqa

import warnings
warnings.warn("The pandas.parser module is deprecated and will be "
"removed in a future version. Please import from "
"the pandas.io.parser instead", FutureWarning, stacklevel=2)
from pandas.io.libparsers import na_values
from pandas.io.common import CParserError
4 changes: 2 additions & 2 deletions pandas/sparse/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
_astype_nansafe, _find_common_type)
from pandas.types.missing import isnull, notnull, na_value_for_dtype

from pandas._sparse import SparseIndex, BlockIndex, IntIndex
import pandas._sparse as splib
from pandas.sparse import libsparse as splib
from pandas.sparse.libsparse import SparseIndex, BlockIndex, IntIndex
import pandas.index as _index
import pandas.core.algorithms as algos
import pandas.core.ops as ops
Expand Down
2 changes: 1 addition & 1 deletion pandas/sparse/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pandas.types.common import is_scalar
from pandas.sparse.array import SparseArray
from pandas.util.validators import validate_bool_kwarg
import pandas._sparse as splib
import pandas.sparse.libsparse as splib


class SparseList(PandasObject):
Expand Down
4 changes: 2 additions & 2 deletions pandas/sparse/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

from pandas.sparse.array import (make_sparse, _sparse_array_op, SparseArray,
_make_index)
from pandas._sparse import BlockIndex, IntIndex
import pandas._sparse as splib
from pandas.sparse.libsparse import BlockIndex, IntIndex
import pandas.sparse.libsparse as splib

from pandas.sparse.scipy_sparse import (_sparse_series_to_coo,
_coo_to_sparse_series)
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions pandas/src/ujson/python/ujson.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static PyMethodDef ujsonMethods[] = {

static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"_pandasujson",
"_libjson",
0, /* m_doc */
-1, /* m_size */
ujsonMethods, /* m_methods */
Expand All @@ -90,14 +90,14 @@ static struct PyModuleDef moduledef = {
NULL /* m_free */
};

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

#else

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

#endif
Expand Down
24 changes: 20 additions & 4 deletions pandas/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ class TestPDApi(Base, tm.TestCase):
# top-level sub-packages
lib = ['api', 'compat', 'computation', 'core',
'indexes', 'formats', 'pandas',
'test', 'tools', 'tseries',
'test', 'tools', 'tseries', 'sparse',
'types', 'util', 'options', 'io']

# top-level packages that are c-imports, should rename to _*
# to avoid naming conflicts
lib_to_rename = ['algos', 'hashtable', 'tslib', 'msgpack', 'sparse',
'json', 'lib', 'index', 'parser']
lib_to_rename = ['algos', 'hashtable', 'tslib',
'lib', 'index']

# these are already deprecated; awaiting removal
deprecated_modules = ['stats', 'datetools']
deprecated_modules = ['stats', 'datetools', 'parser', 'json']

# misc
misc = ['IndexSlice', 'NaT']
Expand Down Expand Up @@ -225,3 +225,19 @@ def test_deprecation_access_obj(self):
with tm.assert_produces_warning(FutureWarning,
check_stacklevel=False):
pd.datetools.monthEnd


class TestJson(tm.TestCase):

def test_deprecation_access_func(self):
with tm.assert_produces_warning(FutureWarning,
check_stacklevel=False):
pd.json.dumps([])


class TestParser(tm.TestCase):

def test_deprecation_access_func(self):
with tm.assert_produces_warning(FutureWarning,
check_stacklevel=False):
pd.parser.na_values
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np

from pandas.compat import (lmap, range, lrange, StringIO, u)
from pandas.parser import ParserError
from pandas.io.common import ParserError
from pandas import (DataFrame, Index, Series, MultiIndex, Timestamp,
date_range, read_csv, compat, to_datetime)
import pandas as pd
Expand Down
Loading