You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scipy's ndimage has a few routines that are very similar to specific funcs in aggregate. In particular, extrema may deal with max min in the way that is needed here.
I've not benchmarked it.
The text was updated successfully, but these errors were encountered:
import numpy as np
from scipy.ndimage.measurements import maximum
from numpy_groupies import aggregate
rnd = np.random.RandomState(seed=100)
group_idx = np.repeat(np.arange(1000), 2)
rnd.shuffle(group_idx)
group_idx = np.repeat(group_idx, 10)
a = rnd.randn(group_idx.size)
%timeit maximum(a, labels=group_idx, index=np.unique(group_idx))
# 1000 loops, best of 3: 1.76 ms per loop
%timeit aggregate(group_idx, a, 'max')
# 10000 loops, best of 3: 87.1 µs per loop
# And even without the unique, no big difference
%timeit np.unique(group_idx)
# 1000 loops, best of 3: 407 µs per loop
So, we can still sleep well having the fastest implementation around. :p
scipy's ndimage has a few routines that are very similar to specific funcs in aggregate. In particular, extrema may deal with
max min
in the way that is needed here.I've not benchmarked it.
The text was updated successfully, but these errors were encountered: