Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/search.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function searchsortednearest(vec::AbstractVector, x)
return idx
end
# Base only specializes searching ranges by Numbers; so optimize for Intervals
function Base.searchsorted(a::Range, I::ClosedInterval)
function Base.searchsorted(a::AbstractVector, I::ClosedInterval)
searchsortedfirst(a, I.left):searchsortedlast(a, I.right)
end

Expand Down
6 changes: 6 additions & 0 deletions test/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ A = AxisArray(reshape(1:32, 2, 2, 2, 2, 2), .1:.1:.2, .1:.1:.2, .1:.1:.2, [:a, :
@test A[ClosedInterval(.15, .25), ClosedInterval(.05, .15), ClosedInterval(.15, .25), :a] == A.data[2:2, 1:1, 2:2, 1, :]
@test A[Axis{:dim_5}(2)] == A.data[:, :, :, :, 2]

# allow SortedVector to force Dimensional behaviour when comparison is possible
A = AxisArray([1,3,2], Axis{:a}(SortedVector(["one", "three", "two"])))
@test A["three"] == 3
@test A["three".."three"] == A["thra".."thro"] == AxisArray([3], Axis{:a}(SortedVector(["three"])))
@test A["a".."z"] == A

# Test vectors
v = AxisArray(collect(.1:.1:10.0), .1:.1:10.0)
@test v[Colon()] == v
Expand Down