Skip to content

Commit

Permalink
allow Periodic() to be used even when converting different units of s…
Browse files Browse the repository at this point in the history
…ame dimension
  • Loading branch information
cmichelenstrofer committed Jul 3, 2023
1 parent a33350f commit a2d1e41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/derived.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ julia> uconvert(u"radᵃ/s", 1u"Hz", Periodic())
```
"""
struct Periodic <: Equivalence end
@eqrelation Periodic (AngularVelocity / Frequency=2π * radᵃ)
@eqrelation Periodic (Frequency * Time=1)
@eqrelation Periodic (AngularVelocity * Time=2π * radᵃ)
@eqrelation Periodic (AngularVelocity / Frequency = 2π * radᵃ)
@eqrelation Periodic (Frequency * Time = 1)
@eqrelation Periodic (AngularVelocity * Time = 2π * radᵃ)
# so that it defaults to `uconvert` behavior
@eqrelation Periodic (AngularVelocity / AngularVelocity = 1)
@eqrelation Periodic (Frequency / Frequency = 1)
@eqrelation Periodic (Time / Time = 1)
3 changes: 3 additions & 0 deletions test/test_core_package.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ end
@test uconvert(u"s", 10u"Hz", Periodic()) 0.1u"s"
@test uconvert(u"s", 2u"radᵃ/s", Periodic()) (π)u"s"
@test uconvert(u"radᵃ/s", (π)u"s", Periodic()) 2u"radᵃ/s"
@test uconvert(u"radᵃ/s", 10u"radᵃ/s", Periodic()) 10u"radᵃ/s"
@test uconvert(u"1/s", 10u"1/s", Periodic()) 10u"1/s"
@test uconvert(u"s", 10u"s", Periodic()) 10u"s"
end

@testset "DefaultSymbols" begin
Expand Down

0 comments on commit a2d1e41

Please sign in to comment.