Skip to content

Commit

Permalink
Add support for tanpi function (#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
sostock authored Jul 30, 2023
1 parent 07eed0a commit d71d2ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/quantities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ sqrt(x::AbstractQuantity) = Quantity(sqrt(x.val), sqrt(unit(x)))
cbrt(x::AbstractQuantity) = Quantity(cbrt(x.val), cbrt(unit(x)))

for _y in (:sin, :cos, :tan, :asin, :acos, :atan, :sinh, :cosh, :tanh, :asinh, :acosh, :atanh,
:sinpi, :cospi, :sinc, :cosc, :cis, :cispi, :sincospi)
:sinpi, :cospi, :tanpi, :sinc, :cosc, :cis, :cispi, :sincospi)
if isdefined(Base, _y)
@eval Base.$(_y)(x::DimensionlessQuantity) = Base.$(_y)(uconvert(NoUnits, x))
end
Expand Down
7 changes: 6 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Unitful:
ac,
mg, g, kg,
Ra, °F, °C, K,
rad, °,
rad, mrad, °,
ms, s, minute, hr, d, yr, Hz,
J, A, N, mol, V,
mW, W,
Expand Down Expand Up @@ -751,6 +751,11 @@ Base.:(<=)(x::Issue399, y::Issue399) = x.num <= y.num
if isdefined(Base, :sincospi)
@test @inferred(sincospi(rad/2)) === (1.0, 0.0)
end
if isdefined(Base, :tanpi)
@test @inferred(tanpi(1f0rad)) === tanpi(1f0)
@test @inferred(tanpi(250mrad)) === tanpi(0.25)
@test @inferred(tanpi(-100mm/m)) === tanpi(-1//10)
end

@test @inferred(atan(m*sqrt(3),1m)) 60°
@test @inferred(atan(m*sqrt(3),1.0m)) 60°
Expand Down

0 comments on commit d71d2ff

Please sign in to comment.