This line will go away if you change to `np.searchsorted`, but please use the idiom `if len(blah) > 0:`.   This makes the code explicit instead of relying on an implicit boolean conversion of 0 to False.