Skip to content
Merged
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 Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "OffsetArrays"
uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
version = "1.14.1"
version = "1.14.2"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
31 changes: 18 additions & 13 deletions src/OffsetArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -824,24 +824,29 @@

centered(A::AbstractArray, i::CartesianIndex) = centered(A, Tuple(i))

# we may pass the searchsorted* functions to the parent, and wrap the offset
for f in [:searchsortedfirst, :searchsortedlast, :searchsorted]
_safe_f = Symbol("_safe_" * String(f))
@eval function $_safe_f(v::OffsetVector, x, ilo, ihi, o::Base.Ordering)
offset = v.offsets[1]
$f(parent(v), x, ilo - offset, ihi - offset, o) .+ offset
end
@eval Base.$f(v::OffsetVector, x, ilo::T, ihi::T, o::Base.Ordering) where T<:Integer =
$_safe_f(v, x, ilo, ihi, o)
end
if VERSION < v"1.12.0-DEV.1713"
# The Base implementations are fixed in https://github.com/JuliaLang/julia/pull/56464 and https://github.com/JuliaLang/julia/pull/56474
# we therefore limit these specializations to older versions of julia

if VERSION <= v"1.2"
# ambiguity warnings in earlier versions
# we may pass the searchsorted* functions to the parent, and wrap the offset
for f in [:searchsortedfirst, :searchsortedlast, :searchsorted]
_safe_f = Symbol("_safe_" * String(f))
@eval Base.$f(v::OffsetVector, x, ilo::Int, ihi::Int, o::Base.Ordering) =
@eval function $_safe_f(v::OffsetVector, x, ilo, ihi, o::Base.Ordering)
offset = v.offsets[1]
$f(parent(v), x, ilo - offset, ihi - offset, o) .+ offset
end
@eval Base.$f(v::OffsetVector, x, ilo::T, ihi::T, o::Base.Ordering) where T<:Integer =

Check warning on line 838 in src/OffsetArrays.jl

View check run for this annotation

Codecov / codecov/patch

src/OffsetArrays.jl#L838

Added line #L838 was not covered by tests
$_safe_f(v, x, ilo, ihi, o)
end

if VERSION <= v"1.2"
# ambiguity warnings in earlier versions
for f in [:searchsortedfirst, :searchsortedlast, :searchsorted]
_safe_f = Symbol("_safe_" * String(f))
@eval Base.$f(v::OffsetVector, x, ilo::Int, ihi::Int, o::Base.Ordering) =
$_safe_f(v, x, ilo, ihi, o)
end
end
end

if VERSION < v"1.1.0-DEV.783"
Expand Down
Loading