docs: def cart_to_polar(arr_c):
      """Return cartesian vectors in their polar representation.
  
      Parameters
      ----------
      arr_c: array, shape (a1, a2, ..., d)
          Cartesian vectors, with last axis indexing the dimension.
  
      Returns
      -------
      arr_p: array, shape of arr_c
          Polar vectors, using (radius, inclination, azimuth) convention.
      """
      if arr_c.shape[-1] == 1:
          arr_p = arr_c.copy()
      elif arr_c.shape[-1] == 2:
          arr_p = np.empty_like(arr_c)
          arr_p[..., 0] = vector_mag(arr_c)
          arr_p[..., 1] = np.arctan2(arr_c[..., 1], arr_c[..., 0])
      elif arr_c.shape[-1] == 3:
          arr_p = np.empty_like(arr_c)
          arr_p[..., 0] = vector_mag(arr_c)
          arr_p[..., 1] = np.arccos(arr_c[..., 2] / arr_p[..., 0])
          arr_p[..., 2] = np.arctan2(arr_c[..., 1], arr_c[..., 0])
      else:
          raise Exception('Invalid vector for polar representation')
      return arr_p