Skip to content

Commit

Permalink
Make haskey work for LazyArray
Browse files Browse the repository at this point in the history
  • Loading branch information
jonniediegelman committed Jul 26, 2024
1 parent 664eb73 commit 4fdfe36
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ComponentArrays"
uuid = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
authors = ["Jonnie Diegelman <[email protected]>"]
version = "0.15.15"
version = "0.15.16"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
2 changes: 2 additions & 0 deletions src/lazyarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Base.propertynames(a::LazyArray) = propertynames(first(a))

Base.keys(a::LazyArray) = Base.OneTo(length(a))

Base.haskey(a::LazyArray, i::Integer) = i in keys(a)

Base.iterate(a::LazyArray) = iterate(getfield(a, :gen))
Base.iterate(a::LazyArray, state...) = iterate(getfield(a, :gen), state...)

Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ end
@test propertynames(ca2) == (:a, :b, :c) # ComponentArray
@test propertynames(ca2.b) == (:a, :b) # LazyArray

@test haskey(ca2, :a) # ComponentArray
@test haskey(ca2.b, 1) # LazyArray

@test keys(ca2) == (:a, :b, :c)
@test keys(ca2.b) == Base.OneTo(2)
end
Expand Down

0 comments on commit 4fdfe36

Please sign in to comment.