Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add modf #539

Merged
merged 2 commits into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@ 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)
rashidrafeek marked this conversation as resolved.
Show resolved Hide resolved
@test modf(-250cm/m) === (-1//2, -2//1)
@test_throws MethodError modf(1m)
@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