nodes: 0, module; 1, function_definition; 2, function_name:validate_wavelengths; 3, parameters; 4, block; 5, identifier:wavelengths; 6, expression_statement; 7, if_statement; 8, if_statement; 9, expression_statement; 10, comment:# Check for zeroes; 11, if_statement; 12, comment:# Check for monotonicity; 13, expression_statement; 14, if_statement; 15, comment:# Check for duplicate values; 16, if_statement; 17, comment:"""Check wavelengths for ``synphot`` compatibility.
  
      Wavelengths must satisfy these conditions:
  
          * valid unit type, if given
          * no zeroes
          * monotonic ascending or descending
          * no duplicate values
  
      Parameters
      ----------
      wavelengths : array-like or `~astropy.units.quantity.Quantity`
          Wavelength values.
  
      Raises
      ------
      synphot.exceptions.SynphotError
          Wavelengths unit type is invalid.
  
      synphot.exceptions.DuplicateWavelength
          Wavelength array contains duplicate entries.
  
      synphot.exceptions.UnsortedWavelength
          Wavelength array is not monotonic.
  
      synphot.exceptions.ZeroWavelength
          Negative or zero wavelength occurs in wavelength array.
  
      """; 18, call; 19, block; 20, else_clause; 21, call; 22, block; 23, assignment; 24, call; 25, block; 26, assignment; 27, not_operator; 28, block; 29, comparison_operator:wave.size > 1; 30, block; 31, identifier:isinstance; 32, argument_list; 33, expression_statement; 34, expression_statement; 35, block; 36, attribute; 37, argument_list; 38, expression_statement; 39, identifier:wave; 40, call; 41, attribute; 42, argument_list; 43, raise_statement; 44, identifier:sorted_wave; 45, call; 46, call; 47, if_statement; 48, attribute; 49, integer:1; 50, expression_statement; 51, if_statement; 52, identifier:wavelengths; 53, attribute; 54, call; 55, assignment; 56, expression_statement; 57, identifier:np; 58, identifier:isscalar; 59, identifier:wave; 60, assignment; 61, attribute; 62, argument_list; 63, identifier:np; 64, identifier:any; 65, comparison_operator:wave <= 0; 66, call; 67, attribute; 68, argument_list; 69, attribute; 70, argument_list; 71, call; 72, block; 73, else_clause; 74, identifier:wave; 75, identifier:size; 76, assignment; 77, call; 78, block; 79, identifier:u; 80, identifier:Quantity; 81, attribute; 82, argument_list; 83, identifier:wave; 84, attribute; 85, assignment; 86, identifier:wave; 87, list; 88, identifier:np; 89, identifier:asarray; 90, identifier:wave; 91, identifier:wave; 92, integer:0; 93, attribute; 94, argument_list; 95, identifier:np; 96, identifier:sort; 97, identifier:wave; 98, identifier:np; 99, identifier:alltrue; 100, comparison_operator:sorted_wave == wave; 101, attribute; 102, argument_list; 103, pass_statement; 104, comment:# Monotonic descending is allowed; 105, block; 106, identifier:dw; 107, binary_operator:sorted_wave[1:] - sorted_wave[:-1]; 108, attribute; 109, argument_list; 110, raise_statement; 111, identifier:units; 112, identifier:validate_wave_unit; 113, attribute; 114, identifier:wavelengths; 115, identifier:value; 116, identifier:wave; 117, identifier:wavelengths; 118, identifier:wave; 119, identifier:exceptions; 120, identifier:ZeroWavelength; 121, string; 122, keyword_argument; 123, identifier:sorted_wave; 124, identifier:wave; 125, identifier:np; 126, identifier:alltrue; 127, comparison_operator:sorted_wave[::-1] == wave; 128, raise_statement; 129, subscript; 130, subscript; 131, identifier:np; 132, identifier:any; 133, comparison_operator:dw == 0; 134, call; 135, identifier:wavelengths; 136, identifier:unit; 137, string_content:Negative or zero wavelength occurs in wavelength array; 138, identifier:rows; 139, subscript; 140, subscript; 141, identifier:wave; 142, call; 143, identifier:sorted_wave; 144, slice; 145, identifier:sorted_wave; 146, slice; 147, identifier:dw; 148, integer:0; 149, attribute; 150, argument_list; 151, call; 152, integer:0; 153, identifier:sorted_wave; 154, slice; 155, attribute; 156, argument_list; 157, integer:1; 158, unary_operator; 159, identifier:exceptions; 160, identifier:DuplicateWavelength; 161, string; 162, keyword_argument; 163, attribute; 164, argument_list; 165, unary_operator; 166, identifier:exceptions; 167, identifier:UnsortedWavelength; 168, string; 169, keyword_argument; 170, integer:1; 171, string_content:Wavelength array contains duplicate entries; 172, identifier:rows; 173, subscript; 174, identifier:np; 175, identifier:where; 176, comparison_operator:wave <= 0; 177, integer:1; 178, string_content:Wavelength array is not monotonic; 179, identifier:rows; 180, subscript; 181, call; 182, integer:0; 183, identifier:wave; 184, integer:0; 185, call; 186, integer:0; 187, attribute; 188, argument_list; 189, attribute; 190, argument_list; 191, identifier:np; 192, identifier:where; 193, comparison_operator:dw == 0; 194, identifier:np; 195, identifier:where; 196, comparison_operator:sorted_wave != wave; 197, identifier:dw; 198, integer:0; 199, identifier:sorted_wave; 200, identifier:wave
code: def validate_wavelengths(wavelengths):
      """Check wavelengths for ``synphot`` compatibility.
  
      Wavelengths must satisfy these conditions:
  
          * valid unit type, if given
          * no zeroes
          * monotonic ascending or descending
          * no duplicate values
  
      Parameters
      ----------
      wavelengths : array-like or `~astropy.units.quantity.Quantity`
          Wavelength values.
  
      Raises
      ------
      synphot.exceptions.SynphotError
          Wavelengths unit type is invalid.
  
      synphot.exceptions.DuplicateWavelength
          Wavelength array contains duplicate entries.
  
      synphot.exceptions.UnsortedWavelength
          Wavelength array is not monotonic.
  
      synphot.exceptions.ZeroWavelength
          Negative or zero wavelength occurs in wavelength array.
  
      """
      if isinstance(wavelengths, u.Quantity):
          units.validate_wave_unit(wavelengths.unit)
          wave = wavelengths.value
      else:
          wave = wavelengths
  
      if np.isscalar(wave):
          wave = [wave]
  
      wave = np.asarray(wave)
  
      # Check for zeroes
      if np.any(wave <= 0):
          raise exceptions.ZeroWavelength(
              'Negative or zero wavelength occurs in wavelength array',
              rows=np.where(wave <= 0)[0])
  
      # Check for monotonicity
      sorted_wave = np.sort(wave)
      if not np.alltrue(sorted_wave == wave):
          if np.alltrue(sorted_wave[::-1] == wave):
              pass  # Monotonic descending is allowed
          else:
              raise exceptions.UnsortedWavelength(
                  'Wavelength array is not monotonic',
                  rows=np.where(sorted_wave != wave)[0])
  
      # Check for duplicate values
      if wave.size > 1:
          dw = sorted_wave[1:] - sorted_wave[:-1]
          if np.any(dw == 0):
              raise exceptions.DuplicateWavelength(
                  'Wavelength array contains duplicate entries',
                  rows=np.where(dw == 0)[0])