Skip to content

Commit

Permalink
Add modf for dimensionless quantities
Browse files Browse the repository at this point in the history
  • Loading branch information
rashidrafeek committed May 19, 2022
1 parent 960e09e commit 4141b2b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/quantities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ end
Base.mod2pi(x::DimensionlessQuantity) = mod2pi(uconvert(NoUnits, x))
Base.mod2pi(x::AbstractQuantity{S, NoDims, <:Units{(Unitful.Unit{:Degree, NoDims}(0, 1//1),),
NoDims}}) where S = mod(x, 360°)
Base.modf(x::DimensionlessQuantity) = modf(uconvert(NoUnits, x))

# Addition / subtraction
for op in [:+, :-]
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ end
@test mod(1hr+3minute+5s, 24s) == 17s
@test mod2pi(360°) === 0° # 2pi is 360°
@test mod2pi(0.5pi*u"m/dm") pi # just testing the dimensionless fallback
@test modf(2.5rad) === (0.5, 2.0)
@test @inferred(inv(s)) === s^-1
@test inv(ContextUnits(m,km)) === ContextUnits(m^-1,km^-1)
@test inv(FixedUnits(m)) === FixedUnits(m^-1)
Expand Down

0 comments on commit 4141b2b

Please sign in to comment.