Skip to content

Commit

Permalink
deprecation tslib
Browse files Browse the repository at this point in the history
  • Loading branch information
jreback committed Mar 1, 2017
1 parent eaa9472 commit df4f898
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
json = _DeprecatedModule(deprmod='pandas.json', deprmodto='pandas.io.json.libjson')
parser = _DeprecatedModule(deprmod='pandas.parser', deprmodto='pandas.io.libparsers')
lib = _DeprecatedModule(deprmod='pandas.lib', deprmodto='pandas.libs.lib')
tslib = _DeprecatedModule(deprmod='pandas.tslib', deprmodto='pandas.libs.tslib')

# use the closest tagged version if possible
from ._version import get_versions
Expand Down
13 changes: 12 additions & 1 deletion pandas/tests/api/test_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-

from warnings import catch_warnings
import numpy as np

import pandas as pd
Expand Down Expand Up @@ -37,7 +38,8 @@ class TestPDApi(Base, tm.TestCase):
'types', 'util', 'options', 'io', 'libs']

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

# misc
misc = ['IndexSlice', 'NaT']
Expand Down Expand Up @@ -244,3 +246,12 @@ def test_deprecation_access_func(self):
with tm.assert_produces_warning(FutureWarning,
check_stacklevel=False):
pd.lib.infer_dtype


class TestTSLib(tm.TestCase):

def test_deprecation_access_func(self):
# some libraries may be imported before we
# test and could show the warning
with catch_warnings(record=True):
pd.tslib.Timestamp
7 changes: 7 additions & 0 deletions pandas/tslib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# flake8: noqa

import warnings
warnings.warn("The pandas.tslib module is deprecated and will be "
"removed in a future version. Please import from "
"the pandas.libs.tslib instead", FutureWarning, stacklevel=2)
from pandas.libs.tslib import Timestamp, Timedelta, NaT
5 changes: 4 additions & 1 deletion pandas/util/depr_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ def __getattr__(self, name):

return obj

def _import_deprmod(self, mod):
def _import_deprmod(self, mod=None):
if mod is None:
mod = self.deprmod

with warnings.catch_warnings():
warnings.filterwarnings('ignore', category=FutureWarning)
deprmodule = importlib.import_module(mod)
Expand Down

0 comments on commit df4f898

Please sign in to comment.