From: A. Unique TensorFlower Date: Mon, 26 Feb 2018 16:04:09 +0000 (-0800) Subject: Drop the getcallargs extension as its logic had to be moved to a higher level into... X-Git-Tag: upstream/v1.7.0~31^2~381 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=546d30232a07c790de55ea75795f24614312c12a;p=platform%2Fupstream%2Ftensorflow.git Drop the getcallargs extension as its logic had to be moved to a higher level into api.py. PiperOrigin-RevId: 187022717 --- diff --git a/tensorflow/contrib/py2tf/pyct/inspect_utils.py b/tensorflow/contrib/py2tf/pyct/inspect_utils.py index c1af95e..d19c6ed 100644 --- a/tensorflow/contrib/py2tf/pyct/inspect_utils.py +++ b/tensorflow/contrib/py2tf/pyct/inspect_utils.py @@ -50,33 +50,6 @@ def getnamespace(f): return namespace -def getcallargs(c, *args, **kwargs): - """Extension of getcallargs to non-function callables.""" - if tf_inspect.isfunction(c) or tf_inspect.ismethod(c): - # The traditional getcallargs - return tf_inspect.getcallargs(c, *args, **kwargs) - - if tf_inspect.isclass(c): - # Constructors: use a sentinel to remove the self argument. - self_sentinel = object() - arg_map = tf_inspect.getcallargs( - c.__init__, self_sentinel, *args, **kwargs) - # Find and remove the self arg. We cannot assume it's called 'self'. - self_arg_name = None - for name, value in arg_map.items(): - if value is self_sentinel: - self_arg_name = name - break - del arg_map[self_arg_name] - return arg_map - - if hasattr(c, '__call__'): - # Callable objects: map self to the object itself - return tf_inspect.getcallargs(c.__call__, *args, **kwargs) - - raise NotImplementedError('unknown callable "%s"' % type(c)) - - def getmethodclass(m): """Resolves a function's owner, e.g. a method's class. diff --git a/tensorflow/contrib/py2tf/pyct/inspect_utils_test.py b/tensorflow/contrib/py2tf/pyct/inspect_utils_test.py index d96c3df..5528ac8 100644 --- a/tensorflow/contrib/py2tf/pyct/inspect_utils_test.py +++ b/tensorflow/contrib/py2tf/pyct/inspect_utils_test.py @@ -127,42 +127,6 @@ class InspectUtilsTest(test.TestCase): self.assertEqual(ns['closed_over_primitive'], closed_over_primitive) self.assertTrue('local_var' not in ns) - def test_getcallargs_constructor(self): - - class TestSuperclass(object): - - def __init__(self, x): - pass - - class TestCallable(TestSuperclass): - pass - - self.assertDictEqual({ - 'x': 1 - }, inspect_utils.getcallargs(TestCallable, 1)) - - def test_getcallargs_object(self): - - class TestCallable(object): - - def __call__(self, x): - pass - - obj = TestCallable() - self.assertDictEqual({ - 'self': obj, - 'x': 1 - }, inspect_utils.getcallargs(obj, 1)) - - def test_getcallargs_function(self): - - def test_fn(x): - return x + 1 - - self.assertDictEqual({ - 'x': 1 - }, inspect_utils.getcallargs(test_fn, 1)) - def test_getmethodclass(self): self.assertEqual(