Skip to content

Commit

Permalink
Merge pull request #6827 from bashtage/fix-6826
Browse files Browse the repository at this point in the history
BUG: Fix missing str
  • Loading branch information
bashtage committed Jun 28, 2020
2 parents a44b79e + b1d666d commit f196c09
Show file tree
Hide file tree
Showing 4 changed files with 253 additions and 174 deletions.
25 changes: 20 additions & 5 deletions statsmodels/tools/validation/__init__.py
@@ -1,7 +1,22 @@
from .validation import (array_like, bool_like, dict_like,
float_like, int_like, PandasWrapper,
required_int_like, string_like)
from .validation import (
array_like,
bool_like,
dict_like,
float_like,
int_like,
PandasWrapper,
required_int_like,
string_like,
)


__all__ = ['array_like', 'bool_like', 'dict_like', 'float_like', 'int_like',
'PandasWrapper', 'required_int_like', 'string_like']
__all__ = [
"array_like",
"bool_like",
"dict_like",
"float_like",
"int_like",
"PandasWrapper",
"required_int_like",
"string_like",
]
24 changes: 18 additions & 6 deletions statsmodels/tools/validation/decorators.py
Expand Up @@ -5,25 +5,37 @@
import statsmodels.tools.validation.validation as v


def array_like(pos, name, dtype=np.double, ndim=None, maxdim=None,
shape=None, order='C', contiguous=False):
def array_like(
pos,
name,
dtype=np.double,
ndim=None,
maxdim=None,
shape=None,
order="C",
contiguous=False,
):
def inner(func):
@wraps(func)
def wrapper(*args, **kwargs):
if pos < len(args):
arg = args[pos]
arg = v.array_like(arg, name, dtype, ndim, maxdim, shape,
order, contiguous)
arg = v.array_like(
arg, name, dtype, ndim, maxdim, shape, order, contiguous
)
if pos == 0:
args = (arg,) + args[1:]
else:
args = args[:pos] + (arg,) + args[pos + 1:]
else:
arg = kwargs[name]
arg = v.array_like(arg, name, dtype, ndim, maxdim, shape,
order, contiguous)
arg = v.array_like(
arg, name, dtype, ndim, maxdim, shape, order, contiguous
)
kwargs[name] = arg

return func(*args, **kwargs)

return wrapper

return inner

0 comments on commit f196c09

Please sign in to comment.