Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aggregate - check performance of scipy ndimage #11

Closed
d1manson opened this issue Aug 5, 2015 · 1 comment
Closed

aggregate - check performance of scipy ndimage #11

d1manson opened this issue Aug 5, 2015 · 1 comment
Labels

Comments

@d1manson
Copy link
Collaborator

d1manson commented Aug 5, 2015

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.

@ml31415
Copy link
Owner

ml31415 commented Apr 23, 2018

Just had a quick benchmark:

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

@ml31415 ml31415 closed this as completed Apr 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants