parameters: (shallow_tree, input_tree, check_types=True)
docstring: 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:
    ```python
      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:
    ```python
      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: if `True` (default) the sequence types of `shallow_tree` and
        `input_tree` have to be the same.
  
    Raises:
      TypeError: If `shallow_tree` is a sequence but `input_tree` is not.
      TypeError: If the sequence types of `shallow_tree` are different from
        `input_tree`. Only raised if `check_types` is `True`.
      ValueError: If the sequence lengths of `shallow_tree` are different from
        `input_tree`.
docstring_summary: Asserts that `shallow_tree` is a shallow structure of `input_tree`.
docstring_tokens: Asserts that shallow_tree is a shallow structure of input_tree .
function: def assert_shallow_structure(shallow_tree, input_tree, check_types=True):
    """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:
    ```python
      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:
    ```python
      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: if `True` (default) the sequence types of `shallow_tree` and
        `input_tree` have to be the same.
  
    Raises:
      TypeError: If `shallow_tree` is a sequence but `input_tree` is not.
      TypeError: If the sequence types of `shallow_tree` are different from
        `input_tree`. Only raised if `check_types` is `True`.
      ValueError: If the sequence lengths of `shallow_tree` are different from
        `input_tree`.
    """
    if is_sequence(shallow_tree):
      if not is_sequence(input_tree):
        raise TypeError(
            "If shallow structure is a sequence, input must also be a sequence. "
            "Input has type: %s." % type(input_tree))
  
      if check_types and not isinstance(input_tree, type(shallow_tree)):
        raise TypeError(
            "The two structures don't have the same sequence type. Input "
            "structure has type %s, while shallow structure has type %s."
            % (type(input_tree), type(shallow_tree)))
  
      if len(input_tree) != len(shallow_tree):
        raise ValueError(
            "The two structures don't have the same sequence length. Input "
            "structure has length %s, while shallow structure has length %s."
            % (len(input_tree), len(shallow_tree)))
  
      if check_types and isinstance(shallow_tree, dict):
        if set(input_tree) != set(shallow_tree):
          raise ValueError(
              "The two structures don't have the same keys. Input "
              "structure has keys %s, while shallow structure has keys %s." %
              (list(input_tree), list(shallow_tree)))
        input_tree = list(sorted(_six.iteritems(input_tree)))
        shallow_tree = list(sorted(_six.iteritems(shallow_tree)))
  
      for shallow_branch, input_branch in zip(shallow_tree, input_tree):
        assert_shallow_structure(shallow_branch, input_branch,
                                 check_types=check_types)
function_tokens: def assert_shallow_structure ( shallow_tree , input_tree , check_types = True ) : if is_sequence ( shallow_tree ) : if not is_sequence ( input_tree ) : raise TypeError ( "If shallow structure is a sequence, input must also be a sequence. " "Input has type: %s." % type ( input_tree ) ) if check_types and not isinstance ( input_tree , type ( shallow_tree ) ) : raise TypeError ( "The two structures don't have the same sequence type. Input " "structure has type %s, while shallow structure has type %s." % ( type ( input_tree ) , type ( shallow_tree ) ) ) if len ( input_tree ) != len ( shallow_tree ) : raise ValueError ( "The two structures don't have the same sequence length. Input " "structure has length %s, while shallow structure has length %s." % ( len ( input_tree ) , len ( shallow_tree ) ) ) if check_types and isinstance ( shallow_tree , dict ) : if set ( input_tree ) != set ( shallow_tree ) : raise ValueError ( "The two structures don't have the same keys. Input " "structure has keys %s, while shallow structure has keys %s." % ( list ( input_tree ) , list ( shallow_tree ) ) ) input_tree = list ( sorted ( _six . iteritems ( input_tree ) ) ) shallow_tree = list ( sorted ( _six . iteritems ( shallow_tree ) ) ) for shallow_branch , input_branch in zip ( shallow_tree , input_tree ) : assert_shallow_structure ( shallow_branch , input_branch , check_types = check_types )