[SciPy-user] Finding min/max indices satisfying a predicate
Daishi Harada
daishi at egcrc.net
Mon Jun 7 19:28:05 EDT 2004
Hi,
I am wondering if there is a canonical recipe for doing the following
efficiently/without using list comprehensions:
min_index = min([i for i in xrange(len(x)) if predicate(x[i])])
where x is some numarray. In particular I would be interested in some
mechanism which is O(min_index) instead of O(len(x)). (I am currently
using the naive basic python version of the O(min_index) search,
but was curious if there was something built in to scipy). FWIW, the
predicates that I am interested in are as simple as x[i] >
SOME_CONSTANT.
Thanks,
d
More information about the SciPy-User
mailing list