old_contents: """
  Utility functions for desispec
  """
  
  import numpy as np
  
  def night2ymd(night):
      """
      parse night YEARMMDD string into tuple of integers (year, month, day)
      """
      assert isinstance(night, str), 'night is not a string'
      assert len(night) == 8, 'invalid YEARMMDD night string '+night
      
      year = int(night[0:4])
      month = int(night[4:6])
      day = int(night[6:8])
      if month < 1 or 12 < month:
          raise ValueError('YEARMMDD month should be 1-12, not {}'.format(month))
      if day < 1 or 31 < day:
          raise ValueError('YEARMMDD day should be 1-31, not {}'.format(day))
          
      return (year, month, day)
      
  def ymd2night(year, month, day):
      """
      convert year, month, day integers into cannonical YEARMMDD night string
      """
      return "{:04d}{:02d}{:02d}".format(year, month, day)
      
  def combine_ivar(ivar1, ivar2):
      """
      Returns the combined inverse variance of two inputs, making sure not to
      divide by 0 in the process.
      
      ivar1 and ivar2 may be scalar or ndarray but must have the same dimensions
      """
      iv1 = np.asarray(ivar1)  #- handle list, tuple, ndarray, and scalar input
      iv2 = np.asarray(ivar2)
      assert np.all(iv1 >= 0), 'ivar1 has negative elements'
      assert np.all(iv2 >= 0), 'ivar2 has negative elements'
      assert iv1.shape == iv2.shape, 'shape mismatch {} vs. {}'.format(iv1.shape, iv2.shape)
      ii = (iv1 > 0) & (iv2 > 0)
      ivar = np.zeros(iv1.shape)
      ivar[ii] = 1.0 / (1.0/iv1[ii] + 1.0/iv2[ii])
      
      #- Convert back to python float if input was scalar
      #- NOTE: if input was 0-dimensional ndarray, this strips
      if isinstance(ivar1, (float, int)):
          return float(ivar)
      else:
          return ivar
      
new_contents: """
  Utility functions for desispec
  """
  
  import numpy as np
  
  def night2ymd(night):
      """
      parse night YEARMMDD string into tuple of integers (year, month, day)
      """
      assert isinstance(night, str), 'night is not a string'
      assert len(night) == 8, 'invalid YEARMMDD night string '+night
      
      year = int(night[0:4])
      month = int(night[4:6])
      day = int(night[6:8])
      if month < 1 or 12 < month:
          raise ValueError('YEARMMDD month should be 1-12, not {}'.format(month))
      if day < 1 or 31 < day:
          raise ValueError('YEARMMDD day should be 1-31, not {}'.format(day))
          
      return (year, month, day)
      
  def ymd2night(year, month, day):
      """
      convert year, month, day integers into cannonical YEARMMDD night string
      """
      return "{:04d}{:02d}{:02d}".format(year, month, day)
      
  def combine_ivar(ivar1, ivar2):
      """
      Returns the combined inverse variance of two inputs, making sure not to
      divide by 0 in the process.
      
      ivar1 and ivar2 may be scalar or ndarray but must have the same dimensions
      """
      iv1 = np.atleast_1d(ivar1)  #- handle list, tuple, ndarray, and scalar input
      iv2 = np.atleast_1d(ivar2)
      assert np.all(iv1 >= 0), 'ivar1 has negative elements'
      assert np.all(iv2 >= 0), 'ivar2 has negative elements'
      assert iv1.shape == iv2.shape, 'shape mismatch {} vs. {}'.format(iv1.shape, iv2.shape)
      ii = (iv1 > 0) & (iv2 > 0)
      ivar = np.zeros(iv1.shape)
      ivar[ii] = 1.0 / (1.0/iv1[ii] + 1.0/iv2[ii])
      
      #- Convert back to python float if input was scalar
      #- NOTE: if input was 0-dimensional ndarray, this strips
      if isinstance(ivar1, (float, int)):
          return float(ivar)
      else:
          return ivar
      
subject: update combine_ivar to support old numpy 1.8