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
It would be nice if np.searchsorted could have an option to return both the left and right insertion indices. This change would be backwards compatible and roughly functionally equivalent to:
But, naturally, implemented so as to take advantage of the fact that the left and right indices are likely to be close, thus enabling some redundant searching to be avoided.
A use case for this is when you want to replace ranges of values in an array. From a real piece of code:
ls=np.searchsorted(con, mfrom, side='left')
le=np.searchsorted(con, mfrom, side='right')
fors, e, tinzip(ls, le, mto):
con[s:e] =t
where there are a pair of calls to np.searchsorted which is then iterated over to yield ranges. This would be simplified under the new proposal to a single such call.
The text was updated successfully, but these errors were encountered:
Proposed new feature or change:
It would be nice if
np.searchsorted
could have an option to return both the left and right insertion indices. This change would be backwards compatible and roughly functionally equivalent to:But, naturally, implemented so as to take advantage of the fact that the left and right indices are likely to be close, thus enabling some redundant searching to be avoided.
A use case for this is when you want to replace ranges of values in an array. From a real piece of code:
where there are a pair of calls to
np.searchsorted
which is then iterated over to yield ranges. This would be simplified under the new proposal to a single such call.The text was updated successfully, but these errors were encountered: