From d71d2fffa2ddd5516148a0bbb4484bd694ba5e11 Mon Sep 17 00:00:00 2001 From: Sebastian Stock <42280794+sostock@users.noreply.github.com> Date: Sun, 30 Jul 2023 13:36:25 +0200 Subject: [PATCH] Add support for `tanpi` function (#620) --- src/quantities.jl | 2 +- test/runtests.jl | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/quantities.jl b/src/quantities.jl index 96469b21..6d47729a 100644 --- a/src/quantities.jl +++ b/src/quantities.jl @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index 75a54750..38d4c7e6 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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, @@ -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°