On main at a02743ebe1f7f42e601633685735596062fc7764, get_std_histogram_buckets adds infinite samples to the first/last bins and then appends another degenerate infinity bin containing samples already counted.
Reproduction
import numpy as np
from nvflare.app_common.abstract.statistics_spec import BinRange
from nvflare.app_common.statistics.numpy_utils import get_std_histogram_buckets
bins = get_std_histogram_buckets(
np.array([-np.inf, 0., np.inf]), 3, BinRange(-1., 1.)
)
print(len(bins), sum(b.sample_count for b in bins))
Actual: 4 4, despite requesting three bins for three samples.
Expected: three bins and a total count of three, with negative and positive infinities included once in their respective edge buckets.
There is a related one-bin case: an elif prevents both infinity endpoints from being added to the same bucket. Using independent endpoint checks preserves a single bucket with bounds (-inf, inf) when both are present.
The duplicate counts also reach the dataframe statistics implementation and global histogram aggregation. Reproduced on macOS, Python 3.12.11 and NumPy 2.5.3, using an explicitly supplied finite histogram range. Automatic range inference with infinite values is outside this report.
On
mainata02743ebe1f7f42e601633685735596062fc7764,get_std_histogram_bucketsadds infinite samples to the first/last bins and then appends another degenerate infinity bin containing samples already counted.Reproduction
Actual:
4 4, despite requesting three bins for three samples.Expected: three bins and a total count of three, with negative and positive infinities included once in their respective edge buckets.
There is a related one-bin case: an
elifprevents both infinity endpoints from being added to the same bucket. Using independent endpoint checks preserves a single bucket with bounds(-inf, inf)when both are present.The duplicate counts also reach the dataframe statistics implementation and global histogram aggregation. Reproduced on macOS, Python 3.12.11 and NumPy 2.5.3, using an explicitly supplied finite histogram range. Automatic range inference with infinite values is outside this report.