Skip to content

Commit

Permalink
Fix for Julia v1.11 (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbauman authored Dec 9, 2024
1 parent beb5622 commit 409db44
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/InvertedIndices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,15 @@ end

# This is an interesting need — we need this because otherwise indexing with a
# single multidimensional boolean array ends up comparing a multidimensional cartesian
# index to a linear index. Does this need addressing in Base, too?
# index to a linear index.
@inline Base.to_indices(A, I::Tuple{Not{<:NIdx{1}}}) = to_indices(A, (eachindex(IndexLinear(), A),), I)
@inline Base.to_indices(A, I::Tuple{Not{<:NIdx}}) = to_indices(A, axes(A), I)
# Arrays of Bool are even more confusing as they're sometimes linear and sometimes not
@inline Base.to_indices(A, I::Tuple{Not{<:AbstractArray{Bool, 1}}}) = to_indices(A, (eachindex(IndexLinear(), A),), I)
@inline Base.to_indices(A, I::Tuple{Not{<:Union{Array{Bool}, BitArray}}}) = to_indices(A, (eachindex(A),), I)
if VERSION < v"1.11.0-DEV.1157"
# Arrays of Bool are even more confusing as they're sometimes linear and sometimes not
# This was addressed in Base with JuliaLang/julia#45869.
@inline Base.to_indices(A, I::Tuple{Not{<:AbstractArray{Bool, 1}}}) = to_indices(A, (eachindex(IndexLinear(), A),), I)
@inline Base.to_indices(A, I::Tuple{Not{<:Union{Array{Bool}, BitArray}}}) = to_indices(A, (eachindex(A),), I)
end

# a cleaner implementation is nt[filter(∉(I.skip), keys(nt))] instead of Base.structdiff, but this would only work on Julia 1.7+
@inline Base.getindex(nt::NamedTuple, I::InvertedIndex{Symbol}) =
Expand Down

0 comments on commit 409db44

Please sign in to comment.