def binmax(bins, maxthis):
size = bins.max() + 1
minmax = maxthis.min()
newmax = maxthis - minmax
a = np.zeros(bins.max() + 1, dtype=maxthis.dtype)
for i, b in enumerate(bins):
val = newmax[i]
a[b] = np.maximum(a[b], val)
return a + minmax
binmax(
np.array([0, 0, 0, 1, 1, 1]),
np.array([2, 5, 0, 100, 200, 50])
)