[Numpy-discussion] searchsorted

Jonathan Taylor jonathan.taylor at stanford.edu
Fri Jun 2 14:08:25 EDT 2006


I was wondering if there was an easy way to get searchsorted to be 
"right-continuous" instead of "left-continuous".

By continuity, I am talking about the continuity of the function "count" 
below...

 >>> import numpy as N
 >>>
 >>> x = N.arange(20)
 >>> x.searchsorted(9)
9
 >>> import numpy as N
 >>>
 >>> x = N.arange(20)
 >>>
 >>> def count(u):
...     return x.searchsorted(u)
...
 >>> count(9)
9
 >>> count(9.01)
10
 >>>

Thanks,

Jonathan

-- 
------------------------------------------------------------------------
I'm part of the Team in Training: please support our efforts for the
Leukemia and Lymphoma Society!

http://www.active.com/donate/tntsvmb/tntsvmbJTaylor

GO TEAM !!!

------------------------------------------------------------------------
Jonathan Taylor                           Tel:   650.723.9230
Dept. of Statistics                       Fax:   650.725.8977
Sequoia Hall, 137                         www-stat.stanford.edu/~jtaylo
390 Serra Mall
Stanford, CA 94305

-------------- next part --------------
A non-text attachment was scrubbed...
Name: jonathan.taylor.vcf
Type: text/x-vcard
Size: 329 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20060602/30ace179/attachment.vcf>


More information about the NumPy-Discussion mailing list