-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Open
Description
Summing over the histogram should always give the number of non-masked records when no weighting is used. As shown below, the sum is reduced, but not by the correct amount. Calling the "compressed()" method and reshaping before running the histogram produces correct results.
The following uses numpy 1.8.1.
x = ma.arange(300).reshape(100,3)
In [5]: print x[:,0].count()
100
In [6]: H,e = np.histogramdd(x)
In [7]: H.sum()
Out[7]: 100.0
In [8]: for i in range(10) :
...: x[i*i,:]=ma.masked
...:
In [9]: print x[:,0].count()
90
In [10]: H,e = np.histogramdd(x)
In [11]: H.sum()
Out[11]: 98.0
x = x.compressed().reshape(90,3)
H,e = np.histogramdd(x)
H.sum()
Out[14]: 90.0