support unsorted segment intervals#203
Conversation
|
TODO:
|
|
I think we should punt on rewriting Otherwise, I think this one's ready for CR from @craffel or @urinieto . (Should be an easy one.) |
|
(PS: speedy resolution of this would be appreciated, as it's stalling a project i'm working on.) |
| if intervals.size > 0: | ||
| # Make sure intervals start at 0 | ||
| if not np.allclose(intervals[0, 0], 0.0): | ||
| if not np.allclose(intervals.min(), 0.0): |
There was a problem hiding this comment.
This, and the max call below, could be made 2x faster as intervals[:, 0].min() and intervals[:, 1].max() respectively.
There was a problem hiding this comment.
Nope 😁 the slice construction dominates runtime for the range of values we care about.
N = 100
x = np.random.randn(N, 2)
%timeit x.min()
100000 loops, best of 3: 1.9 µs per loop
%timeit x[:, 0].min()
100000 loops, best of 3: 1.92 µs per loop|
Looks reasonable to me. I am not an expert on |
|
Cool, thanks. I didn't make any substantive changes to The logic is: for each time point |
|
Ok, cool. |
|
@craffel thanks for the CR. Unless you object, I think this is merge-ready. |
|
Feel free to squash and merge. |
simplified interval sorting, adjust_intervals no longer needs ordered input added tests for util.sort_labeled_intervals
This is a bugfix for issue #202.