nodes: 0, module; 1, function_definition; 2, function_name:check_levels; 3, parameters; 4, block; 5, identifier:imls; 6, identifier:imt; 7, default_parameter; 8, expression_statement; 9, if_statement; 10, identifier:min_iml; 11, float:1E-10; 12, comment:"""
      Raise a ValueError if the given levels are invalid.
  
      :param imls: a list of intensity measure and levels
      :param imt: the intensity measure type
      :param min_iml: minimum intensity measure level (default 1E-10)
  
      >>> check_levels([0.1, 0.2], 'PGA')  # ok
      >>> check_levels([], 'PGA')
      Traceback (most recent call last):
         ...
      ValueError: No imls for PGA: []
      >>> check_levels([0.2, 0.1], 'PGA')
      Traceback (most recent call last):
         ...
      ValueError: The imls for PGA are not sorted: [0.2, 0.1]
      >>> check_levels([0.2, 0.2], 'PGA')
      Traceback (most recent call last):
         ...
      ValueError: Found duplicated levels for PGA: [0.2, 0.2]
      """; 13, comparison_operator:len(imls) < 1; 14, block; 15, elif_clause; 16, elif_clause; 17, elif_clause; 18, elif_clause; 19, call; 20, integer:1; 21, raise_statement; 22, comparison_operator:imls != sorted(imls); 23, block; 24, comparison_operator:len(distinct(imls)) < len(imls); 25, block; 26, boolean_operator; 27, comment:# apply the cutoff; 28, block; 29, boolean_operator; 30, comment:# apply the cutoff; 31, block; 32, identifier:len; 33, argument_list; 34, call; 35, identifier:imls; 36, call; 37, raise_statement; 38, call; 39, call; 40, raise_statement; 41, comparison_operator:imls[0] == 0; 42, comparison_operator:imls[1] <= min_iml; 43, raise_statement; 44, comparison_operator:imls[0] == 0; 45, comparison_operator:imls[1] > min_iml; 46, expression_statement; 47, identifier:imls; 48, identifier:ValueError; 49, argument_list; 50, identifier:sorted; 51, argument_list; 52, call; 53, identifier:len; 54, argument_list; 55, identifier:len; 56, argument_list; 57, call; 58, subscript; 59, integer:0; 60, subscript; 61, identifier:min_iml; 62, call; 63, subscript; 64, integer:0; 65, subscript; 66, identifier:min_iml; 67, assignment; 68, binary_operator:'No imls for %s: %s' % (imt, imls); 69, identifier:imls; 70, identifier:ValueError; 71, argument_list; 72, call; 73, identifier:imls; 74, identifier:ValueError; 75, argument_list; 76, identifier:imls; 77, integer:0; 78, identifier:imls; 79, integer:1; 80, identifier:ValueError; 81, argument_list; 82, identifier:imls; 83, integer:0; 84, identifier:imls; 85, integer:1; 86, subscript; 87, identifier:min_iml; 88, string; 89, tuple; 90, binary_operator:'The imls for %s are not sorted: %s' % (imt, imls); 91, identifier:distinct; 92, argument_list; 93, binary_operator:"Found duplicated levels for %s: %s" % (imt, imls); 94, binary_operator:"The min_iml %s=%s is larger than the second level "
                           "for %s" % (imt, min_iml, imls); 95, identifier:imls; 96, integer:0; 97, string_content:No imls for %s: %s; 98, identifier:imt; 99, identifier:imls; 100, string; 101, tuple; 102, identifier:imls; 103, string:"Found duplicated levels for %s: %s"; 104, tuple; 105, concatenated_string; 106, tuple; 107, string_content:The imls for %s are not sorted: %s; 108, identifier:imt; 109, identifier:imls; 110, identifier:imt; 111, identifier:imls; 112, string:"The min_iml %s=%s is larger than the second level "; 113, string:"for %s"; 114, identifier:imt; 115, identifier:min_iml; 116, identifier:imls
code: def check_levels(imls, imt, min_iml=1E-10):
      """
      Raise a ValueError if the given levels are invalid.
  
      :param imls: a list of intensity measure and levels
      :param imt: the intensity measure type
      :param min_iml: minimum intensity measure level (default 1E-10)
  
      >>> check_levels([0.1, 0.2], 'PGA')  # ok
      >>> check_levels([], 'PGA')
      Traceback (most recent call last):
         ...
      ValueError: No imls for PGA: []
      >>> check_levels([0.2, 0.1], 'PGA')
      Traceback (most recent call last):
         ...
      ValueError: The imls for PGA are not sorted: [0.2, 0.1]
      >>> check_levels([0.2, 0.2], 'PGA')
      Traceback (most recent call last):
         ...
      ValueError: Found duplicated levels for PGA: [0.2, 0.2]
      """
      if len(imls) < 1:
          raise ValueError('No imls for %s: %s' % (imt, imls))
      elif imls != sorted(imls):
          raise ValueError('The imls for %s are not sorted: %s' % (imt, imls))
      elif len(distinct(imls)) < len(imls):
          raise ValueError("Found duplicated levels for %s: %s" % (imt, imls))
      elif imls[0] == 0 and imls[1] <= min_iml:  # apply the cutoff
          raise ValueError("The min_iml %s=%s is larger than the second level "
                           "for %s" % (imt, min_iml, imls))
      elif imls[0] == 0 and imls[1] > min_iml:  # apply the cutoff
          imls[0] = min_iml