tf.contrib.framework.nest.assert_shallow_structure(
shallow_tree,
input_tree,
check_types=True
)
Defined in tensorflow/python/util/nest.py
.
Asserts that shallow_tree
is a shallow structure of input_tree
.
That is, this function tests if the input_tree
structure can be created from
the shallow_tree
structure by replacing its leaf nodes with deeper
tree structures.
Examples:
The following code will raise an exception:
shallow_tree = ["a", "b"]
input_tree = ["c", ["d", "e"], "f"]
assert_shallow_structure(shallow_tree, input_tree)
The following code will not raise an exception:
shallow_tree = ["a", "b"]
input_tree = ["c", ["d", "e"]]
assert_shallow_structure(shallow_tree, input_tree)
Args:
shallow_tree
: an arbitrarily nested structure.input_tree
: an arbitrarily nested structure.check_types
: ifTrue
(default) the sequence types ofshallow_tree
andinput_tree
have to be the same. Note that even with check_types==True, this function will consider two different namedtuple classes with the same name and _fields attribute to be the same class.
Raises:
TypeError
: Ifshallow_tree
is a sequence butinput_tree
is not.TypeError
: If the sequence types ofshallow_tree
are different frominput_tree
. Only raised ifcheck_types
isTrue
.ValueError
: If the sequence lengths ofshallow_tree
are different frominput_tree
.