Skip to content

Commit

Permalink
Merge pull request #2 from JuliaActuary/fix_rate_dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
alecloudenback authored Aug 11, 2022
2 parents 8527f9e + 211034e commit 23ac8f8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 104 deletions.
100 changes: 0 additions & 100 deletions docs/Manifest.toml

This file was deleted.

8 changes: 4 additions & 4 deletions src/Rates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ function Base.:+(a::Real, b::Rate{N,T}) where {N<:Real, T<:Periodic}
return Periodic(b.value + a,b.compounding.frequency)
end

function Base.:+(a::Rate{N,T},b::Rate{N,T}) where {N<:Real,T<:CompoundingFrequency}
function Base.:+(a::Rate{N,T},b::Rate{N,U}) where {N<:Real,T,U}
a_rate = rate(a)
b_rate = rate(convert(a.compounding,b))
r = Rate(a_rate + b_rate,a.compounding)
Expand Down Expand Up @@ -359,7 +359,7 @@ end
function Base.:-(a::Real, b::Rate{N,T}) where {N<:Real, T<:Periodic}
return Periodic(a - b.value, b.compounding.frequency)
end
function Base.:-(a::Rate{N,T},b::Rate{N,T}) where {N<:Real,T<:CompoundingFrequency}
function Base.:-(a::Rate{N,U},b::Rate{N,U}) where {N<:Real,T,U}
a_rate = rate(a)
b_rate = rate(convert(a.compounding,b))
r = Rate(a_rate - b_rate,a.compounding)
Expand Down Expand Up @@ -424,7 +424,7 @@ julia> Yields.Periodic(0.03,100) < Yields.Continuous(0.03)
true
```
"""
function Base.:<(a::Rate{N,T},b::Rate{N,U}) where {N<:Real,T<:CompoundingFrequency,U<:CompoundingFrequency}
function Base.:<(a::Rate{N,T},b::Rate{N,U}) where {N<:Real,T,U}
bc = convert(a.compounding,b)
return rate(a) < rate(bc)
end
Expand All @@ -441,7 +441,7 @@ julia> Yields.Periodic(0.03,100) > Yields.Continuous(0.03)
false
```
"""
function Base.:>(a::Rate{N,T},b::Rate{N,U}) where {N<:Real,T<:CompoundingFrequency,U<:CompoundingFrequency}
function Base.:>(a::Rate{N,T},b::Rate{N,U}) where {N<:Real,T,U}
bc = convert(a.compounding,b)
return rate(a) > rate(bc)
end
3 changes: 3 additions & 0 deletions test/Rates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@

@test p(a) + b Periodic(0.05,1)
@test a + p(b) Periodic(0.05,1)

@test p(a) + c(b) p(a) + Periodic(1)(c(b))
@test c(a) + p(b) c(a) + Continuous()(p(b))
end

@testset "multiplication" begin
Expand Down

0 comments on commit 23ac8f8

Please sign in to comment.