diff --git a/src/core.jl b/src/core.jl index 190152a..1cdf42a 100644 --- a/src/core.jl +++ b/src/core.jl @@ -240,9 +240,9 @@ function AxisArray(A::AbstractArray{T,N}, names::NTuple{N,Symbol}, steps::NTuple end # Alternative constructor, takes names as keywords: -AxisArray(A; kw...) = AxisArray(A, nt_to_axes(kw.data)...) -@generated nt_to_axes(nt::NamedTuple) = - Expr(:tuple, (:(Axis{$(QuoteNode(n))}(getfield(nt, $(QuoteNode(n))))) for n in nt.names)...) +AxisArray(A; kw...) = AxisArray(A, nt_to_axes(values(kw))) +@generated nt_to_axes(nt::NamedTuple{names}) where {names} = + Expr(:tuple, (:(Axis{$(QuoteNode(n))}(getfield(nt, $(QuoteNode(n))))) for n in names)...) AxisArray(A::AxisArray) = A AxisArray(A::AxisArray, ax::Vararg{Axis, N}) where N = diff --git a/src/indexing.jl b/src/indexing.jl index 4e4a482..b50e82d 100644 --- a/src/indexing.jl +++ b/src/indexing.jl @@ -160,11 +160,11 @@ end # Keyword indexing, reconstructs the Axis{}() objects @propagate_inbounds Base.view(A::AxisArray; kw...) = - view(A, kw_to_axes(parent(A), kw.data)...) + view(A, kw_to_axes(parent(A), values(kw))...) @propagate_inbounds Base.getindex(A::AxisArray; kw...) = - getindex(A, kw_to_axes(parent(A), kw.data)...) + getindex(A, kw_to_axes(parent(A), values(kw))...) @propagate_inbounds Base.setindex!(A::AxisArray, val; kw...) = - setindex!(A, val, kw_to_axes(parent(A), kw.data)...) + setindex!(A, val, kw_to_axes(parent(A), values(kw))...) function kw_to_axes(A::AbstractArray, nt::NamedTuple) length(nt) == 0 && throw(BoundsError(A, ())) # Trivial case A[] lands here diff --git a/test/intervals.jl b/test/intervals.jl index f3840fb..80464e3 100644 --- a/test/intervals.jl +++ b/test/intervals.jl @@ -27,8 +27,8 @@ v = [1 .. 2, 3.0 .. 4.0] @test 4 in 2.0 .. 6.0 @test 4 in 4.0 .. 4.0 @test 4 in 4.0 .. 5 -@test (1..2) in (0.5 .. 2.5) -@test !((1..2) in (1.5 .. 2.5)) +@test (1..2) ⊆ (0.5 .. 2.5) +@test !((1..2) ⊆ (1.5 .. 2.5)) @test maximum(1..2) === 2 @test minimum(1..2) === 1