Closed
Description
In trying to refactor IntervalIndex.get_loc/get_value to more closely follow the other implementations, I stumbled on a behavior in a test case that surprised me:
idx = IntervalIndex.from_tuples([(1, 5), (3, 7)])
s = Series(range(len(idx)), index=idx)
key = [4]
>>> idx.get_loc(key) # <-- behaves like all the other get_locs in requiring scalar
KeyError: [4]
>>> idx.get_value(s, key) # <-- surprising
(1, 5] 0
(3, 7] 1
dtype: int64
All of the other FooIndex.get_value methods raise InvalidIndexError on non-scalar.
AFAICT this is behaving sort of like a slicing operation, since 4 is in the interior of both of these intervals. @jschendel is that correct? If so, we should try to refactor IntervalIndex.get_value to explicitly dispatch for this case, kind of like DatetimeIndex._get_string_slice