code: def add_densities(density1, density2):
      
      return {spin: np.array(density1[spin]) + np.array(density2[spin])
              for spin in density1.keys()}
docs: Method to sum two densities.
  
      Args:
          density1: First density.
          density2: Second density.
  
      Returns:
          Dict of {spin: density}.