Skip to content

Commit

Permalink
Merge pull request #34 from mmikhasenko/feature-vcat
Browse files Browse the repository at this point in the history
feature: vcat
  • Loading branch information
mmikhasenko authored May 26, 2024
2 parents 6ed521e + 079d4b8 commit 88a8674
Show file tree
Hide file tree
Showing 4 changed files with 30 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 = "ThreeBodyDecays"
uuid = "e6563dab-9ca1-5843-bde3-2ccf38d63843"
authors = ["Misha Mikhasenko <[email protected]>"]
version = "0.11.2"
version = "0.11.3"

[deps]
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Expand Down
2 changes: 1 addition & 1 deletion src/ThreeBodyDecays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using RecipesBase
using Polynomials
using PolynomialRoots

import Base: getindex, iterate, length
import Base: getindex, iterate, length, vcat


export Kallen, sqrtKallenFact, Kibble,
Expand Down
20 changes: 20 additions & 0 deletions src/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,23 @@ Computes squared amplitude summed over spin projections.
unpolarized_intensity(model, σs; kw...) =
sum(abs2, amplitude(model, σs, two_λs; kw...)
for two_λs in itr(spins(model)))


"""
Base.vcat(models::ThreeBodyDecay...)
Concatenates multiple `ThreeBodyDecay` objects into a single `ThreeBodyDecay`.
Argument is variable number of `ThreeBodyDecay` objects.
# An example
```julia
extended_model = vcat(model[2], model[2:3], model)
```
"""
function vcat(models::ThreeBodyDecay...)
names = vcat(getproperty.(models, :names)...)
couplings = vcat(getproperty.(models, :couplings)...)
chains = vcat(getproperty.(models, :chains)...)
ThreeBodyDecay(names .=> zip(couplings, chains))
end

8 changes: 8 additions & 0 deletions test/test_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ end
@test length(_model) == 1
end


@testset "Vertical Concat model" begin
_model = vcat(model[2], model[2:3], model)
@test _model isa ThreeBodyDecay
@test length(_model) == 1 + 2 + 3
end


struct MyDecayChain{T} <: AbstractDecayChain
x::T
end
Expand Down

2 comments on commit 88a8674

@mmikhasenko
Copy link
Owner 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/107701

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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.3 -m "<description of version>" 88a8674b37e646479bcf4e838a70cd027ebb958b
git push origin v0.11.3

Please sign in to comment.