Return true if the object is iterable.
(obj)
| 97 | |
| 98 | # TODO(fkp): very generic code, it should be moved in a more generic place. |
| 99 | def is_iterable(obj): |
| 100 | """Return true if the object is iterable.""" |
| 101 | if isinstance(obj, tf_ops.Tensor): |
| 102 | return False |
| 103 | try: |
| 104 | _ = iter(obj) |
| 105 | except Exception: # pylint: disable=broad-except |
| 106 | return False |
| 107 | return True |
| 108 | |
| 109 | |
| 110 | def flatten_tree(tree, leaves=None): |
no outgoing calls
no test coverage detected