Decision
To calculate the average, we divide the sum by a real number. This separation causes problems due to type advancement (see below). To avoid type advancement, we can manually perform this separation separately for the real and imaginary parts of the sum:
n = 3
s = np.sum([1 + 0j, 2 + 0j, np.inf + 0j])
mean = np.real(s) / n + 1j * np.imag(s) / n
print(mean)
Justification
numpy, , . , ((1 + 0j) + (2 + 0j) + (np.inf + 0j)) / (3+0j)
(inf+nanj)
.
. , . , :
a + bj
--------
c + dj
divisoin , d=0
. , , j
. :
a + bj (a + bj) * (c - dj) ac + bd + bcj - adj
-------- = --------------------- = ---------------------
c + dj (c + dj) * (c - dj) c**2 + d**2
, a=inf
d=0
a * d * j = inf * 0 * j = nan * j
.