Skip to content

Commit 4e29472

Browse files
authored
Fix deprecations with nt.names and kw.data (#201)
also fix a test-only depwarn using IntervalSets
1 parent bf961cf commit 4e29472

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/core.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ function AxisArray(A::AbstractArray{T,N}, names::NTuple{N,Symbol}, steps::NTuple
240240
end
241241

242242
# Alternative constructor, takes names as keywords:
243-
AxisArray(A; kw...) = AxisArray(A, nt_to_axes(kw.data)...)
244-
@generated nt_to_axes(nt::NamedTuple) =
245-
Expr(:tuple, (:(Axis{$(QuoteNode(n))}(getfield(nt, $(QuoteNode(n))))) for n in nt.names)...)
243+
AxisArray(A; kw...) = AxisArray(A, nt_to_axes(values(kw)))
244+
@generated nt_to_axes(nt::NamedTuple{names}) where {names} =
245+
Expr(:tuple, (:(Axis{$(QuoteNode(n))}(getfield(nt, $(QuoteNode(n))))) for n in names)...)
246246

247247
AxisArray(A::AxisArray) = A
248248
AxisArray(A::AxisArray, ax::Vararg{Axis, N}) where N =

src/indexing.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@ end
160160

161161
# Keyword indexing, reconstructs the Axis{}() objects
162162
@propagate_inbounds Base.view(A::AxisArray; kw...) =
163-
view(A, kw_to_axes(parent(A), kw.data)...)
163+
view(A, kw_to_axes(parent(A), values(kw))...)
164164
@propagate_inbounds Base.getindex(A::AxisArray; kw...) =
165-
getindex(A, kw_to_axes(parent(A), kw.data)...)
165+
getindex(A, kw_to_axes(parent(A), values(kw))...)
166166
@propagate_inbounds Base.setindex!(A::AxisArray, val; kw...) =
167-
setindex!(A, val, kw_to_axes(parent(A), kw.data)...)
167+
setindex!(A, val, kw_to_axes(parent(A), values(kw))...)
168168

169169
function kw_to_axes(A::AbstractArray, nt::NamedTuple)
170170
length(nt) == 0 && throw(BoundsError(A, ())) # Trivial case A[] lands here

test/intervals.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ v = [1 .. 2, 3.0 .. 4.0]
2727
@test 4 in 2.0 .. 6.0
2828
@test 4 in 4.0 .. 4.0
2929
@test 4 in 4.0 .. 5
30-
@test (1..2) in (0.5 .. 2.5)
31-
@test !((1..2) in (1.5 .. 2.5))
30+
@test (1..2) (0.5 .. 2.5)
31+
@test !((1..2) (1.5 .. 2.5))
3232

3333
@test maximum(1..2) === 2
3434
@test minimum(1..2) === 1

0 commit comments

Comments
 (0)