Skip to content

Commit 0b8fa9d

Browse files
ranaragjreback
authored andcommitted
DEPR/TST: compat for using signature in test_panel.py, xref #12101
changed deprecated getargspec to signature for python 3 while keeping the getargspec for python 2
1 parent db0094d commit 0b8fa9d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

pandas/compat/__init__.py

+7
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import types
3636
from unicodedata import east_asian_width
3737
import struct
38+
import inspect
3839

3940
PY2 = sys.version_info[0] == 2
4041
PY3 = (sys.version_info[0] >= 3)
@@ -69,6 +70,9 @@ def str_to_bytes(s, encoding=None):
6970
def bytes_to_str(b, encoding=None):
7071
return b.decode(encoding or 'utf-8')
7172

73+
def signature(f):
74+
return list(inspect.signature(f).parameters.keys())
75+
7276
# have to explicitly put builtins into the namespace
7377
range = range
7478
map = map
@@ -105,6 +109,9 @@ def str_to_bytes(s, encoding='ascii'):
105109
def bytes_to_str(b, encoding='ascii'):
106110
return b
107111

112+
def signature(f):
113+
return inspect.getargspec(f).args
114+
108115
# import iterator versions of these functions
109116
range = xrange
110117
zip = itertools.izip

pandas/tests/test_panel.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# pylint: disable=W0612,E1101
33

44
from datetime import datetime
5-
from inspect import getargspec
5+
66
import operator
77
import nose
88
from functools import wraps
@@ -17,7 +17,7 @@
1717
from pandas.core.series import remove_na
1818
import pandas.core.common as com
1919
from pandas import compat
20-
from pandas.compat import range, lrange, StringIO, OrderedDict
20+
from pandas.compat import range, lrange, StringIO, OrderedDict, signature
2121
from pandas import SparsePanel
2222

2323
from pandas.util.testing import (assert_panel_equal, assert_frame_equal,
@@ -198,7 +198,7 @@ def wrapper(x):
198198
self.assertRaises(Exception, f, axis=obj.ndim)
199199

200200
# Unimplemented numeric_only parameter.
201-
if 'numeric_only' in getargspec(f).args:
201+
if 'numeric_only' in signature(f):
202202
self.assertRaisesRegexp(NotImplementedError, name, f,
203203
numeric_only=True)
204204

0 commit comments

Comments
 (0)