code: def convert_2D_cov(*args):
      """Convert a 2D covariance from matrix form to principal form, and back
  
      if one parameter is passed, it is a covariance matrix, and the principal
      axes and rotation (sigma1, sigma2, alpha) are returned.
  
      if three parameters are passed, they are assumed to be (sigma1, sigma2,
      alpha) and the covariance is returned
      """
      if len(args) == 1:
          C = np.asarray(args[0])
          if C.shape != (2, 2):
              raise ValueError("Input not understood")
          sigma_x2 = C[0, 0]
          sigma_y2 = C[1, 1]
          sigma_xy = C[0, 1]
  
          alpha = 0.5 * np.arctan2(2 * sigma_xy, (sigma_x2 - sigma_y2))
          tmp1 = 0.5 * (sigma_x2 + sigma_y2)
          tmp2 = np.sqrt(
              0.25 * (sigma_x2 - sigma_y2) ** 2 + sigma_xy**2
          )
  
          sigma1 = np.sqrt(tmp1 + tmp2)
          sigma2 = np.sqrt(tmp1 - tmp2)
  
          return (sigma1, sigma2, alpha)
  
      elif len(args) == 3:
          sigma1, sigma2, alpha = args
  
          s = np.sin(alpha)
          c = np.cos(alpha)
          sigma_x2 = (sigma1 * c) ** 2 + (sigma2 * s) ** 2
          sigma_y2 = (sigma1 * s) ** 2 + (sigma2 * c) ** 2
          sigma_xy = (sigma1**2 - sigma2**2) * s * c
  
          return np.array([[sigma_x2, sigma_xy], [sigma_xy, sigma_y2]])
  
      else:
          raise ValueError("Input not understood")
  
file_path: astroML/astroML/utils/utils.py
imports: import numpy
  from scipy import linalg
  from sklearn.utils import check_random_state
  from astroML.utils.decorators import deprecated
  from astroML.utils.exceptions import AstroMLDeprecationWarning
label_desc: Use image node_id 6 for calling a global function with example usage: convert_2D_cov() and returns: sigma1,  sigma2,  alpha, np