nodes: 0, module; 1, function_definition; 2, function_name:validate_wavetable; 3, parameters; 4, block; 5, identifier:self; 6, expression_statement; 7, comment:# First check for invalid values; 8, expression_statement; 9, if_statement; 10, comment:# Now check for monotonicity & enforce ascending; 11, expression_statement; 12, if_statement; 13, comment:# Check for duplicate values; 14, expression_statement; 15, if_statement; 16, comment:"""Enforce monotonic, ascending wavelength array with no zero or
          negative values.
  
          Raises
          ------
          pysynphot.exceptions.DuplicateWavelength
              Wavelength array contains duplicate entries.
  
          pysynphot.exceptions.UnsortedWavelength
              Wavelength array is not monotonic ascending or descending.
  
          pysynphot.exceptions.ZeroWavelength
              Wavelength array has zero or negative value(s).
  
          """; 17, assignment; 18, call; 19, block; 20, assignment; 21, not_operator; 22, block; 23, assignment; 24, call; 25, block; 26, identifier:wave; 27, attribute; 28, attribute; 29, argument_list; 30, expression_statement; 31, raise_statement; 32, identifier:sorted; 33, call; 34, call; 35, if_statement; 36, identifier:dw; 37, binary_operator:sorted[1:] - sorted[:-1]; 38, attribute; 39, argument_list; 40, expression_statement; 41, raise_statement; 42, identifier:self; 43, identifier:_wavetable; 44, identifier:N; 45, identifier:any; 46, comparison_operator:wave <= 0; 47, assignment; 48, call; 49, attribute; 50, argument_list; 51, attribute; 52, argument_list; 53, call; 54, comment:# monotonic descending is allowed; 55, block; 56, else_clause; 57, subscript; 58, subscript; 59, identifier:N; 60, identifier:any; 61, comparison_operator:dw == 0; 62, assignment; 63, call; 64, identifier:wave; 65, integer:0; 66, identifier:wrong; 67, subscript; 68, attribute; 69, argument_list; 70, identifier:N; 71, identifier:sort; 72, identifier:wave; 73, identifier:N; 74, identifier:alltrue; 75, comparison_operator:sorted == wave; 76, attribute; 77, argument_list; 78, pass_statement; 79, block; 80, identifier:sorted; 81, slice; 82, identifier:sorted; 83, slice; 84, identifier:dw; 85, integer:0; 86, identifier:wrong; 87, subscript; 88, attribute; 89, argument_list; 90, call; 91, integer:0; 92, identifier:exceptions; 93, identifier:ZeroWavelength; 94, string; 95, keyword_argument; 96, identifier:sorted; 97, identifier:wave; 98, identifier:N; 99, identifier:alltrue; 100, comparison_operator:sorted[::-1] == wave; 101, expression_statement; 102, raise_statement; 103, integer:1; 104, unary_operator; 105, call; 106, integer:0; 107, identifier:exceptions; 108, identifier:DuplicateWavelength; 109, string:"Wavelength array contains duplicate entries"; 110, keyword_argument; 111, attribute; 112, argument_list; 113, string_content:Negative or Zero wavelength occurs in wavelength array; 114, identifier:rows; 115, identifier:wrong; 116, subscript; 117, identifier:wave; 118, assignment; 119, call; 120, integer:1; 121, attribute; 122, argument_list; 123, identifier:rows; 124, identifier:wrong; 125, identifier:N; 126, identifier:where; 127, comparison_operator:wave <= 0; 128, identifier:sorted; 129, slice; 130, identifier:wrong; 131, subscript; 132, attribute; 133, argument_list; 134, identifier:N; 135, identifier:where; 136, comparison_operator:dw == 0; 137, identifier:wave; 138, integer:0; 139, unary_operator; 140, call; 141, integer:0; 142, identifier:exceptions; 143, identifier:UnsortedWavelength; 144, string; 145, keyword_argument; 146, identifier:dw; 147, integer:0; 148, integer:1; 149, attribute; 150, argument_list; 151, string_content:Wavelength array is not monotonic; 152, identifier:rows; 153, identifier:wrong; 154, identifier:N; 155, identifier:where; 156, comparison_operator:sorted != wave; 157, identifier:sorted; 158, identifier:wave
code: def validate_wavetable(self):
          """Enforce monotonic, ascending wavelength array with no zero or
          negative values.
  
          Raises
          ------
          pysynphot.exceptions.DuplicateWavelength
              Wavelength array contains duplicate entries.
  
          pysynphot.exceptions.UnsortedWavelength
              Wavelength array is not monotonic ascending or descending.
  
          pysynphot.exceptions.ZeroWavelength
              Wavelength array has zero or negative value(s).
  
          """
          # First check for invalid values
          wave = self._wavetable
          if N.any(wave <= 0):
              wrong = N.where(wave <= 0)[0]
              raise exceptions.ZeroWavelength(
                  'Negative or Zero wavelength occurs in wavelength array',
                  rows=wrong)
  
          # Now check for monotonicity & enforce ascending
          sorted = N.sort(wave)
          if not N.alltrue(sorted == wave):
              if N.alltrue(sorted[::-1] == wave):
                  # monotonic descending is allowed
                  pass
              else:
                  wrong = N.where(sorted != wave)[0]
                  raise exceptions.UnsortedWavelength(
                      'Wavelength array is not monotonic', rows=wrong)
  
          # Check for duplicate values
          dw = sorted[1:] - sorted[:-1]
          if N.any(dw == 0):
              wrong = N.where(dw == 0)[0]
              raise exceptions.DuplicateWavelength(
                  "Wavelength array contains duplicate entries", rows=wrong)