Skip to content

Commit

Permalink
11-bug-ThreeBodySpins (#43)
Browse files Browse the repository at this point in the history
* fix constructor bug
* patch up
* prettier
  • Loading branch information
mmikhasenko authored Aug 14, 2024
1 parent 77ee004 commit b95d0d2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions .cspell/julia.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ inrange
invperm
isapprox
iseven
isnothing
isodd
isphysical
ispositive
Expand Down
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.12.0"
version = "0.12.1"

[deps]
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Expand Down
14 changes: 7 additions & 7 deletions src/tbs_struct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ function ThreeBodySpins(
two_h1_or_h1,
two_h2_or_h2,
two_h3_or_h3;
h0 = -1, # unrealistic by default
two_h0 = -1,
) # unrealistic by default
h0 = nothing, # default to nothing
two_h0 = nothing, # default to nothing
)
if isnothing(h0) && isnothing(two_h0)
error("Use either `two_h0=...`, or `h0=...` keyword argument.")
end

two_h0 == -1 &&
h0 == -1 &&
return error("Use either two_h0=..., or h0=... key word argument.")
two_hs =
(h0 == -1 && two_h0 != -1) ?
(isnothing(h0) && !isnothing(two_h0)) ?
SpinTuple(Tuple(Int[two_h1_or_h1, two_h2_or_h2, two_h3_or_h3, two_h0])) :
SpinTuple(Tuple([two_h1_or_h1, two_h2_or_h2, two_h3_or_h3, h0] .|> x2))
#
Expand Down
2 changes: 2 additions & 0 deletions test/test_three_body_spins.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ end
@test ThreeBodySpins("1", "1/2", "0"; h0 = "1/2") == ThreeBodySpins(2, 1, 0; two_h0 = 1)
#
@test ThreeBodySpins(1, 1 / 2, 0; h0 = 1 / 2) == ThreeBodySpins(2, 1, 0; two_h0 = 1)
@test all(ThreeBodySpins(1, 1, 0; h0 = i) isa SpinTuple for i = -10:10)
@test all(ThreeBodySpins(1, 2, 0; two_h0 = i) isa SpinTuple for i = -11:2:11)
#
@test_throws ErrorException ThreeBodySpins("0", "1/2", "1/2"; h0 = "1/2")
end
Expand Down

2 comments on commit b95d0d2

@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 register()

@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/113125

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.12.1 -m "<description of version>" b95d0d2fb7ae6dcae6d5b6abfeb5a2a3bda8408c
git push origin v0.12.1

Please sign in to comment.