From c37ba37aaa9f75547393e83b80d16d2bff9f50b4 Mon Sep 17 00:00:00 2001 From: Matt McCann Date: Wed, 13 Jul 2022 12:35:38 +0200 Subject: [PATCH 1/2] Use inspect library to get input argument names For compatibility with python 3, I'm using inspect.getfullargspec to list the input arguments. I added an if-else to check for python version, in case people are still running Python 2. Tested on my local machine. --- pycircstat/descriptive.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pycircstat/descriptive.py b/pycircstat/descriptive.py index dc0d668..3178149 100644 --- a/pycircstat/descriptive.py +++ b/pycircstat/descriptive.py @@ -5,7 +5,9 @@ from functools import wraps import itertools +import sys from decorator import decorator +from inspect import getfullargspec import numpy as np from scipy import stats @@ -34,7 +36,10 @@ def __init__(self, no_bootstrap, scale='linear'): self.scale = scale def _get_var(self, f, what, default, args, kwargs, remove=False): - varnames = f.__code__.co_varnames + if sys.version_info[0] > 2: + varnames = getfullargspec(f).args + else: + varnames = f.__code__.co_varnames if what in varnames: what_idx = varnames.index(what) From e2734a0b700cf2b847292d636f773d114e3d937e Mon Sep 17 00:00:00 2001 From: Matt McCann Date: Wed, 13 Jul 2022 12:55:55 +0200 Subject: [PATCH 2/2] Use inspect.getfullargspec to get function args --- pycircstat/decorators.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pycircstat/decorators.py b/pycircstat/decorators.py index 4862784..021c1c4 100644 --- a/pycircstat/decorators.py +++ b/pycircstat/decorators.py @@ -1,6 +1,8 @@ from __future__ import absolute_import from functools import wraps +from inspect import getfullargspec +import sys import numpy as np from . import CI from decorator import decorator @@ -36,7 +38,10 @@ def wrapper(f, *args, **kwargs): def get_var(f, varnames, args, kwargs): - fvarnames = f.__code__.co_varnames + if sys.version_info[0] > 2: + fvarnames = getfullargspec(f).args + else: + fvarnames = f.__code__.co_varnames var_idx = [] kwar_keys = []