Skip to content
Permalink
Browse files

added missing utils for lime

  • Loading branch information
sytelus committed May 29, 2019
1 parent 8097818 commit 485b0235ba22a696544f9cdf892b6279fc0f32b7
@@ -8,7 +8,7 @@

setuptools.setup(
name="tensorwatch",
version="0.8.3",
version="0.8.4",
author="Shital Shah",
author_email="shitals@microsoft.com",
description="Interactive Realtime Debugging and Visualization for AI",
@@ -24,6 +24,6 @@
),
include_package_data=True,
install_requires=[
'matplotlib', 'numpy', 'pyzmq', 'plotly', 'torchstat', 'receptivefield', 'ipywidgets', 'sklearn', 'nbformat'
'matplotlib', 'numpy', 'pyzmq', 'plotly', 'torchstat', 'receptivefield', 'ipywidgets', 'sklearn', 'nbformat', 'skimage'
]
)
@@ -33,6 +33,7 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="tensorwatch\receptive_field\__init__.py" />
<Compile Include="tensorwatch\saliency\lime\wrappers\generic_utils.py" />
<Compile Include="tensorwatch\stream_union.py">
<SubType>Code</SubType>
</Compile>
@@ -0,0 +1,39 @@
import sys
import inspect
import types


def has_arg(fn, arg_name):
"""Checks if a callable accepts a given keyword argument.
Args:
fn: callable to inspect
arg_name: string, keyword argument name to check
Returns:
bool, whether `fn` accepts a `arg_name` keyword argument.
"""
if sys.version_info < (3,):
if isinstance(fn, types.FunctionType) or isinstance(fn, types.MethodType):
arg_spec = inspect.getargspec(fn)
else:
try:
arg_spec = inspect.getargspec(fn.__call__)
except AttributeError:
return False
return (arg_name in arg_spec.args)
elif sys.version_info < (3, 6):
arg_spec = inspect.getfullargspec(fn)
return (arg_name in arg_spec.args or
arg_name in arg_spec.kwonlyargs)
else:
try:
signature = inspect.signature(fn)
except ValueError:
# handling Cython
signature = inspect.signature(fn.__call__)
parameter = signature.parameters.get(arg_name)
if parameter is None:
return False
return (parameter.kind in (inspect.Parameter.POSITIONAL_OR_KEYWORD,
inspect.Parameter.KEYWORD_ONLY))
@@ -1,5 +1,5 @@
import types
from lime.utils.generic_utils import has_arg
from .generic_utils import has_arg
from skimage.segmentation import felzenszwalb, slic, quickshift


0 comments on commit 485b023

Please sign in to comment.
You can’t perform that action at this time.