diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2018-09-13 11:30:45 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-09-13 11:34:41 -0700 |
commit | ee72b6a204232532e64221f1b9db7843ee13c312 (patch) | |
tree | e5124841e8d65375ac2f4c66637f268115c63308 /tensorflow/python/util | |
parent | 2f886d17f1990da418366bd093a09fb01fe5e777 (diff) |
Automated rollback of commit 56d4fc8ff67f48294ae5cb0a7f9ff3d954463aa3
PiperOrigin-RevId: 212847619
Diffstat (limited to 'tensorflow/python/util')
-rw-r--r-- | tensorflow/python/util/collections.py | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/tensorflow/python/util/collections.py b/tensorflow/python/util/collections.py deleted file mode 100644 index ef5290ee8b..0000000000 --- a/tensorflow/python/util/collections.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2018 The TensorFlow Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -"""Collections utilities.""" - -from __future__ import absolute_import -from __future__ import division -from __future__ import print_function - -import collections - - -def tf_namedtuple(name, fieldnames_and_docs): - """A `namedtuple` class factory that supports field-docstrings. - - ``` - cls = tf_namedtuple("MyNamedTuple",[("a", "Docs for a"), - ("b", "Docs for b")]) - cls.a.__doc__ # ==> "Docs for a" - ``` - - Args: - name: The name of the new class. - fieldnames_and_docs: A sequence of `(fieldname, docstring)` pairs. The - fieldnames are passed to `collections.namedtuple`. - - Returns: - A namedtuple class. - """ - fieldnames_and_docs = list(fieldnames_and_docs) - fieldnames = [fieldname for fieldname, doc in fieldnames_and_docs] - cls = collections.namedtuple(name, fieldnames) - - for fieldname, doc in fieldnames_and_docs: - old_prop = getattr(cls, fieldname) - new_prop = property(fget=old_prop.fget, fset=old_prop.fset, - fdel=old_prop.fdel, doc=doc) - setattr(cls, fieldname, new_prop) - - return cls |