Description
As documented, hist
returns tuple : (n, bins, patches) ...
. In previous versions of matplotlib, n
contained integer values. As of 1.3.0, the data type has changed to float. This change is not documented. It was introduced with commit 6917f4f in the 1.3.x branch and is supposed to fix some internal problem. For 1.2.x, this problem was fixed in a different way, see commit neggert@932dd88. I don't know if the above-mentioned change in 1.2.x also changed the return value data type.
In our case, the data type change has broken application code. Although the data type is not specified in the documentation, we think this change of behavior can be considered a bug and at the least needs to be noted in the changelog. For the future, the right way would be to specify the data type in the documentation.
For convenience, parts of the code in question:
m, bins = np.histogram(x[i], bins, weights=w[i], **hist_kwargs)
m = m.astype(float) # causes problems later if it's an int
if mlast is None:
mlast = np.zeros(len(bins)-1, m.dtype)
if normed and not stacked:
db = np.diff(bins)
m = (m.astype(float) / db) / m.sum()
if stacked:
m += mlast
mlast[:] = m
n.append(m)
Multiple occurrences of m.astype(float)
as well as the m.dtype
in mlast = np.zeros(len(bins)-1, m.dtype)
suggest that there is unreasonable redundancy introduced by the code related to the "stacked" feature.
Thanks for consideration!