Closed bfonta closed 1 year ago
You have a simple storage, counts and values are exactly the same. You have to use a Mean or WeighedMean storage to have separate counts and values. Those don't support multiplication, actually (you can manually build the array & set the view with it, but the * operator isn't supported).
Let us assume I access a histogram that I did not create myself, using a simple storage, and which I know has been scaled. Wouldn't it be useful to know with how many entries the histogram had originally been filled? Given that counts()
and values()
are already defined, this information could potentially be added without significant changes (as far as I can think of). To me (but I may be wrong), the output of counts()
as it is now can be misleading.
I suppose one could alternatively drop the support for the *
operator, but it seems a nice feature to have.
You don't have the information with a simple storage. Simple storage means one value is stored per bin. You can't keep separate counts and values without keeping more information. If you keep more information by using more values, then you should use one of the complex storages.
You can tell if something's been scaled or modified in any way, though - if simple storages's .variances()
returns None, then the histogram was scaled, had at least one value set, or was loaded from data. Or a weight was used when filling. The variances only returns the values array if the histogram has only been filled with simple values and not modified.
FYI, counts is mostly there because values and counts are different things for a Mean or WeightedMean storage. There, "values" refers to the mean of the input sample values, while counts is related to the fill.
Describe the bug
When applying an operation on a histogram, I would expect
.counts
to always return the "number of entries in a bin" (ref).Steps to reproduce
Using Python
3.11.4
and hist2.7.1
:which outputs:
while I would naively expect: