From 4cfb55dd888800ecdb1690829b6f1eb08db3de10 Mon Sep 17 00:00:00 2001 From: Yuto Horikawa Date: Tue, 20 Sep 2022 12:32:01 +0900 Subject: [PATCH] Add deprecated messages for `DualQuaternion` (#93) * add deprecated messages for DualQuaternion * add `@test_deprecated` for DualQuaternion * update depwarn messages for DualQuaternion * update tests for DualQuaternion * remove unnecessary type limitation in the DualQuaternion constructor * add <: Real parameter in the DualQuaternion constructor --- src/DualQuaternion.jl | 8 ++++++++ test/DualQuaternion.jl | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/DualQuaternion.jl b/src/DualQuaternion.jl index da4f3d41..655dd63d 100644 --- a/src/DualQuaternion.jl +++ b/src/DualQuaternion.jl @@ -4,6 +4,14 @@ struct DualQuaternion{T<:Real} <: Number q0::Quaternion{T} qe::Quaternion{T} norm::Bool + function DualQuaternion{T}(q0, qe, norm) where T <: Real + Base.depwarn("`DualQuaternion` is deprecated and will be removed in the next breaking release. Use `Quaternion{ForwardDiff.Dual}` instead.", :DualQuaternion) + return new{T}(q0, qe, norm) + end +end + +function DualQuaternion(q0::Quaternion{T}, qe::Quaternion{T}, norm::Bool) where T <: Real + return DualQuaternion{T}(q0, qe, norm) end DualQuaternion{T}(dq::DualQuaternion) where {T<:Real} = DualQuaternion{T}(dq.q0, dq.qe, dq.norm) diff --git a/test/DualQuaternion.jl b/test/DualQuaternion.jl index d731b4ac..e56c8304 100644 --- a/test/DualQuaternion.jl +++ b/test/DualQuaternion.jl @@ -111,6 +111,12 @@ end DualQuaternion(Quaternion(1.0, 2, 3, 4), Quaternion(1, 2, 3, 4)) end + @testset "deprecated warning" begin + @test_deprecated DualQuaternion(Quaternion(1, 2, 3, 4), Quaternion(5, 6, 7, 8)) + @test_deprecated DualQuaternion{Int}(Quaternion(1, 2, 3, 4), Quaternion(5, 6, 7, 8), false) + @test_deprecated DualQuaternion{Float64}(Quaternion(1, 2, 3, 4), Quaternion(5, 6, 7, 8), false) + end + @testset "convert" begin @test convert(DualQuaternion{Float64}, 1) === DualQuaternion(1.0) @test convert(DualQuaternion{Float64}, DualNumbers.Dual(1, 2)) ===