Skip to content
2 changes: 2 additions & 0 deletions heat/core/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,8 @@ def __merge_moments(
if len(m1) != len(m2):
raise ValueError(f"m1 and m2 must be same length, currently {len(m1)} and {len(m2)}")
n1, n2 = m1[-1], m2[-1]
if (n2 == 0).all():
Comment thread
maliesen marked this conversation as resolved.
Outdated
return m1
mu1, mu2 = m1[-2], m2[-2]
n = n1 + n2
delta = mu2 - mu1
Expand Down
8 changes: 8 additions & 0 deletions tests/core/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1599,3 +1599,11 @@ def test_var(self):

# edge case from #2374
self.assertEqual(ht.var(ht.array([0.], split=None), axis=0, ddof=0), 0)

# meant to be run on four parallel processes (mpirun -n 4)
Comment thread
maliesen marked this conversation as resolved.
Outdated
def test_first_two_leading_ranks_empty(self):
data_all = ht.arange(100., split=0)
data = data_all[data_all >= 50.]
Comment thread
maliesen marked this conversation as resolved.
Outdated

self.assertEqual(ht.mean(data), 74.5)
self.assertEqual(ht.var(data), 208.25)
Comment thread
maliesen marked this conversation as resolved.
Outdated