code: def XYZ_to_xyY(cobj, *args, **kwargs):
      
      xyz_sum = cobj.xyz_x + cobj.xyz_y + cobj.xyz_z
      # avoid division by zero
      if xyz_sum == 0.0:
          xyy_x = 0.0
          xyy_y = 0.0
      else:
          xyy_x = cobj.xyz_x / xyz_sum
          xyy_y = cobj.xyz_y / xyz_sum
      xyy_Y = cobj.xyz_y
  
      return xyYColor(
          xyy_x, xyy_y, xyy_Y, observer=cobj.observer, illuminant=cobj.illuminant)
docs: Convert from XYZ to xyY.