Skip to content

Commit

Permalink
merge method for kwarg splatting. Closes #117
Browse files Browse the repository at this point in the history
  • Loading branch information
jonniedie committed Jan 21, 2022
1 parent 95b34c6 commit dcf2fc0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
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.11.8"
version = "0.11.9"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
2 changes: 2 additions & 0 deletions src/namedtuple_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ Base.propertynames(x::ComponentVector) = propertynames(indexmap(getaxes(x)[1]))

@inline Base.setproperty!(x::ComponentVector, s::Symbol, v) = _setindex!(x, v, Val(s))
@inline Base.setproperty!(x::ComponentVector, s::Val, v) = _setindex!(x, v, s)

Base.merge(a::NamedTuple, b::ComponentArray) = merge(a, NamedTuple(b))
8 changes: 7 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ end

# Issue #116
# Part 2: Arrays of arrays
@test_throws Exception ComponentVector(a=[[3],[4,5]], b=1)
@test_throws Exception ComponentVector(a = [[3], [4, 5]], b = 1)
end

@testset "Attributes" begin
Expand Down Expand Up @@ -138,6 +138,12 @@ end
@test hash(ab, zero(UInt)) != hash(xy, zero(UInt))

@test ab == LVector(a = 1, b = 2)

# Issue #117
kw_fun(; a, b) = a + b
x = ComponentArray(a=4, b=5)
@test merge(NamedTuple(), x) == NamedTuple(x)
@test kw_fun(; x...) == 9
end

@testset "Get" begin
Expand Down

2 comments on commit dcf2fc0

@jonniedie
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/52946

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.11.9 -m "<description of version>" dcf2fc0d154240910473071733dfdcc2c4522833
git push origin v0.11.9

Please sign in to comment.